Article directory
- 1. Zookeeper official website download
- Two, JDK environment installation
- Three, zookeeper installation
-
- 1. zookeeper decompression
- 2. Zookeeper configuration file introduction
- clone server
-
- 1. Network check
- 2. Cluster configuration
- 3. Start the cluster
- 4. Error record
1. Zookeeper official website download
- Download address: https://archive.apache.org/dist/zookeeper/
- Find the corresponding version and download
2. JDK environment installation
- Directly use the
yum
command to install online
yum install -y java-1.8.0-openjdk.x86_64
- Environment variable configuration
sudo vi /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_291/ export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
- reload configuration file
sudo source /etc/profile
3. zookeeper installation
1.zookeeper decompression
- First upload the downloaded
apache-zookeeper-3.5.9-bin.tar.gz
to the server - Unzip and install to the
/usr/local/
directory
tar -zxvf apache-zookeeper-3.5.9-bin.tar.gz -C /usr/local/
-
As shown below
-
Renamed to
zookeeper
mv apache-zookeeper-3.5.9-bin zookeeper
- As shown below
2.zookeeper configuration file introduction
- Enter the
zookeeper
configuration fileusr/local/zookeeper/conf/
- Rename the
zoo_sample.cfg
configuration file tozoo.cfg
mv zoo_sample.cfg zoo.cfg
- Configuration file introduction
# The number of milliseconds of each tick # The actual unit used to calculate the base tickTime=2000 # The number of ticks that the initial # synchronization phase can take # initialization time initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgment # election time syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. # Configure zookeeper data storage path dataDir=/tmp/zookeeper # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1
- First create a storage directory for
zookeeper
data and logs in thezookeeper
directory, and add file read and write permissions
mkdir data sudo chmod 777 data mkdir logs sudo chmod 777 logs
- As shown in the picture
- Modify the configuration file
dataDir=/usr/local/zookeeper/data dataLogDir=/usr/local/zookeeper/logs
- cluster configuration
# cluster configuration 2888: election port 3888: voting port server.1=server001:2888:3888 server.2=server002:2888:3888 server.3=server003:2888:3888
- KAFKA001 represents the host name, and can also write the IP address
- View hostname
hostnamectl
- set hostname
sudo hostnamectl set-hostname server001
- Create the
/usr/local/zookeeper/data
data directory before adding the unique identifier of this machine cluster - Write
1
- Note: the data in
myid
is consistent withservice
echo "1" > myid
- Configure the
host
filevi /etc/hosts
Add the host names and IP addresses of the three clusters
192.168.204.130 server001 192.168.204.131 server002 192.168.204.132 server003
- As shown below
Clone server
- See this article for detailed operations: VMware virtual machine cloning, copying virtual machines
1. Network inspection
- After cloning, check that the three servers can access each other’s IP
2. Cluster configuration
- Remember to modify the hostnames of the latter two servers
sudo hostnamectl set-hostname server002 sudo hostnamectl set-hostname server003
- Create the
/usr/local/zookeeper/data
data directory before and add the unique identifier of this machine cluster [modify the latter two] - The latter two machines respectively write
2
,3
echo "2" > myid echo "3" > myid
3. Start the cluster
- Enter the
/usr/local/zookeeper/bin
directory and execute./zkServer.sh start
# can be executed separately on three servers /usr/local/zookeeper/bin/zkServer.sh start
- check status
# can be executed separately on three servers /usr/local/zookeeper/bin/zkServer.sh status
- As shown below
4. Error record
- If an exception occurs
ERROR
- Execute the command
./zkServer.sh start-foreground
to see the error details in the log to further determine the cause of the error
/usr/local/zookeeper/bin/zkServer.sh start-foreground
- It is necessary to rule out that the firewall is closed first, related commands: CentOS7 [manage firewall port commands]