Compiling and Installing ZooKeeper
- 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.
- 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/
- Configure Maven.
- 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/
- Add a mirror.
1vi /usr/local/apache-maven-3.6.3/conf/settings.xmlAdd 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.
- Decompress apache-maven-3.6.3-bin.tar.gz to the /usr/local directory.
- Set Java and Maven environment variables.
- Modify the environment variables.
1vi /etc/profileAdd 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
- Make the environment variables take effect.
1source /etc/profile
- Check whether the installation is successful.
1mvn -vIf the correct version information is displayed, the installation is successful. If the installation fails, check the installation procedure and try again.
- Modify the environment variables.
- Install the ZooKeeper dependencies.
1yum install cppunit cppunit-devel hostname autoconf libtool libsysfs automake -y
- Compile the ZooKeeper source code.
- Decompress apache-zookeeper-3.6.3.tar.gz.
1 2
cd /home tar -zxvf apache-zookeeper-3.6.3.tar.gz
- Compile zookeeper-jute.
1 2
cd apache-zookeeper-3.6.3/zookeeper-jute mvn clean install -DskipTests
- 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.
- Decompress apache-zookeeper-3.6.3.tar.gz.
- Copy all files in /home/apache-zookeeper-3.6.3/zookeeper-client/zookeeper-client-c/target/c/include/zookeeper to /usr/include.
1cp /home/apache-zookeeper-3.6.3/zookeeper-client/zookeeper-client-c/target/c/include/zookeeper/* /usr/include/
- Copy all files in /home/apache-zookeeper-3.6.3/zookeeper-client/zookeeper-client-c/target/c/lib/ to /usr/lib64.
1cp /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.