Zookeeper starts the specified JDK version
1. Download the jdk21 version from the official website
Java Downloads | Oracle
2. The jdk-21_linux-x64_bin. file will be downloaded
The uploaded host /usr/java directory is below.
3. Unzip the file in the /usr/java directory
tar -zxvf jdk-21_linux-x64_bin.
4. Modify the script below the bin directory of zookeeper
Add the directory where jdk21 is installed before the script line about getting JAVA_HOME.
JAVA_HOME=/usr/java/jdk-21.0.5 if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then JAVA="$JAVA_HOME/bin/java" elif type -p java; then JAVA=java else echo "Error: JAVA_HOME is not set and java could not be found in PATH." 1>&2 exit 1 fi
5. Restart zookeeper
After restarting, check the zookeeper status and check the zookeeper process.
stop start status ps -ef | grep zookeeper
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.