Compiling the Keepalived Binary File

Prerequisites

  • You have obtained the software package in Obtaining the Software Package.
  • You have downloaded the source code of Keepalived 2.2.4 from the Keepalived official website. If this version has vulnerabilities, fix them by yourself.

Procedure

  1. Download the source code of Keepalived 2.2.4 and upload it to any directory in the compilation environment, for example, /home/keepalived.
  2. Upload the patch file in Ascend-mindxedge-keepalived_{version}_linux-{arch}.zip to the directory where the Keepalived source code is stored.
    Table 1 File information

    File or Folder Name

    Information

    keepalived.patch

    Patch file. The path is Ascend-mindxedge-keepalived_{version}_linux-{arch}tar.gz in Ascend-mindxedge-keepalived_{version}_linux-{arch}.zip.

    keepalived-2.2.4

    Keepalived source code.

  3. Run the following command to install the patch for the Keepalived source code:
    patch -p0 < keepalived.patch
  4. Compile the Keepalived binary file.
    1. Run the cd keepalived-2.2.4/ command to switch to the Keepalived source code directory.
    2. Run the ./autogen.sh, ./configure, and make commands in sequence.
      1. If the system displays a message indicating that the dependency check fails after you run the ./autogen.sh and ./configure commands, install all dependencies by referring to Table 2.
      2. If a dependency already exists in the compilation environment or is reinstalled, but the system still displays a message indicating that the dependency check fails, the possible cause is that the corresponding header file is missing.
      3. When running ./configure, you can add CFLAGS as required to use the security options provided by the existing compiler to ensure product security. If the compilation options are set incorrectly, security risks may exist. The recommended compilation setting is ./configure --prefix=/ CFLAGS="-Wall -fstack-protector-all -fPIC -D_FORTIFY_SOURCE=2 -O2 -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -s".

      You can also compile the binary file by referring to the compilation and installation guide in the Keepalived open source community.

      Table 2 Dependency description

      Command

      Required Dependency

      ./autogen.sh

      aclocal/autoheader/automake/autoreconfu

      ./configure

      BSD-compatible gawk/make/pkg-config/gcc/ranlib/ln -s/strip/ldd/ar/openssl, etc.

    After the commands are executed successfully, the compiled binary file is stored in Keepalived-2.2.4/bin/keepalived.