Rate This Document
Findability
Accuracy
Completeness
Readability

Compiling and Installing ZooKeeper

  1. From open source websites, download apache-zookeeper-3.6.3.tar.gz, apache-maven-3.6.3-bin.tar.gz, and OpenJDK8U-jdk_aarch64_linux_hotspot_jdk8u282-b08.tar.gz (ARM) or OpenJDK8U-jdk_x64_linux_hotspot_8u282b08.tar.gz (x86) and save them to /home.
  2. Configure Java.

    In the ARM environment:

    Decompress OpenJDK8U-jdk_aarch64_linux_hotspot_jdk8u282-b08.tar.gz to the /usr/local directory.

    cd /home
    tar -zxvf OpenJDK8U-jdk_aarch64_linux_hotspot_jdk8u282-b08.tar.gz -C /usr/local/

    In the x86 environment:

    Decompress OpenJDK8U-jdk_x64_linux_hotspot_8u282b08.tar.gz to the /usr/local directory.

    cd /home
    tar -zxvf OpenJDK8U-jdk_x64_linux_hotspot_8u282b08.tar.gz -C /usr/local/
  1. Configure Maven.
    1. Decompress apache-maven-3.6.3-bin.tar.gz to the /usr/local directory.
      1
      2
      cd /home
      tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /usr/local/
      
    2. Add a mirror.
      1
      vi /usr/local/apache-maven-3.6.3/conf/settings.xml
      

      Add the following content to <mirrors>:

      1
      2
      3
      4
      5
      <mirror>
          <id>huaweicloud</id>
          <mirrorOf>*</mirrorOf>
          <url>https://repo.huaweicloud.com/repository/maven/</url>
      </mirror>
      

      If no proxy is configured for Maven, add <proxy> to the <proxies> segment of the settings.xml file.

  2. Set Java and Maven environment variables.
    1. Modify the environment variables.
      1
      vi /etc/profile
      

      Add the following content to the end of the file:

      1
      2
      3
      4
      5
      export JAVA_HOME=/usr/local/jdk8u282-b08
      export PATH=${JAVA_HOME}/bin:$PATH
      MAVEN_HOME=/usr/local/apache-maven-3.6.3
      export MAVEN_HOME
      export PATH=${PATH}:$MAVEN_HOME/bin
      
    2. Make the environment variables take effect.
      1
      source /etc/profile
      
    3. Check whether the installation is successful.
      1
      mvn -v
      

      If the correct version information is displayed, the installation is successful. If the installation fails, check the installation procedure and try again.

  3. Install the ZooKeeper dependencies.
    1
    yum install cppunit cppunit-devel hostname autoconf libtool libsysfs automake -y
    
  4. Compile the ZooKeeper source code.
    1. Decompress apache-zookeeper-3.6.3.tar.gz.
      1
      2
      cd /home
      tar -zxvf apache-zookeeper-3.6.3.tar.gz
      
    2. Compile zookeeper-jute.
      1
      2
      cd apache-zookeeper-3.6.3/zookeeper-jute
      mvn clean install -DskipTests
      
    3. Compile zookeeper-c.
      1
      2
      cd ../zookeeper-client/zookeeper-client-c
      mvn clean install -DskipTests
      

      Run the gcc -v command to check whether the GCC version is 7.3.0 or later. If no, run the yum install gcc-7.3.0 command.

  5. Copy all files in /home/apache-zookeeper-3.6.3/zookeeper-client/zookeeper-client-c/target/c/include/zookeeper to /usr/include.
    1
    cp /home/apache-zookeeper-3.6.3/zookeeper-client/zookeeper-client-c/target/c/include/zookeeper/* /usr/include/
    
  6. Copy all files in /home/apache-zookeeper-3.6.3/zookeeper-client/zookeeper-client-c/target/c/lib/ to /usr/lib64.
    1
    cp /home/apache-zookeeper-3.6.3/zookeeper-client/zookeeper-client-c/target/c/lib/* /usr/lib64/
    

You need to package the patches for ZooKeeper security vulnerabilities by yourself.