Zookeeper (two) installation
Local mode installation
Preparation before installation
-
Install jdk
-
Copy apache-zookeeper-3.6.0-bin.tar.gz to the opt directory
-
Unzip the installation package
tar -zxvf apache-zookeeper-3.6.0-bin.tar.gz
-
Rename
mv apache-zookeeper-3.6.0-bin zookeeper
Configuration modification
Create the zkData and zkLog directories on the /opt/zookeeper/ directory
mkdir zkData
mkdir zkLog
Enter the path /opt/zookeeper/conf, copy a zoo_sample.cfg file and name it zoo.cfg
cp zoo_sample.cfg zoo.cfg
Edit the zoo.cfg file and modify the dataDir path
dataDir=/opt/zookeeper/zkData
dataLogDir=/opt/zookeeper/zkLog
Operate Zookeeper
Start Zookeeper
./zkServer.sh start
Check whether the process is started
jps
QuorumPeerMain: is the startup entry class of the zookeeper cluster, which is used to load the configuration to start the QuorumPeer thread
Check status
./zkServer.sh status
Start the client
./zkCli.sh
Exit the client
quit
Interpretation of configuration parameters
The meaning of the parameters in the zoo.cfg configuration file in Zookeeper is interpreted as follows:
-
tickTime = 2000: the number of communication heartbeats, the heartbeat time between Zookeeper server and client, in milliseconds
- The basic time used by Zookeeper is the time interval between servers or between the client and the server to maintain a heartbeat, that is, a heartbeat will be sent every tickTime, and the time unit is milliseconds.
-
initLimit =10: LF initial communication time limit
- The maximum number of heartbeats that can be tolerated at startup between the Follower server and Leader server in the cluster
- 10*2000 (10 heartbeat time) If the leader and follower do not send out heartbeat communication, it is regarded as an invalid connection, and the leader and follower are completely disconnected
-
syncLimit =5: LF synchronization communication time limit
- After the cluster is started, the maximum response time unit between Leader and Follower. If the response exceeds syncLimit *tickTime->10 seconds, Leader thinks that the follower is dead and deletes the follower from the server list
-
dataDir: data file directory + data persistence path
- Mainly used to save data in Zookeeper.
-
dataLogDir: log file directory
-
clientPort =2181: client connection port
- The port that listens for client connections.