zookeeper cluster installation
Environment: centos7.4
IP address: 192.168.215.129
Software: zookeeper-3.4.12
Configuration file Detailed Explanation
After ZooKeeper is installed, you can find a file named “zoo_sample.cfg” in the conf folder of the installation directory, which is a template of the ZooKeeper configuration file.
When ZooKeeper starts, it will load “conf/zoo.cfg” as the configuration file by default, so you need to copy “zoo_sample.cfg” and name it “zoo.cfg”, and then set the configuration items in it as needed .
The configuration item is very simple. The description is as follows:
tickTime=2000
This time is used as the time interval for maintaining the heartbeat between ZooKeeper servers or between the client and the server, that is, one is sent every tickTime time Heartbeat. The unit is milliseconds.
initLimit=10
This configuration item is used to configure the maximum number of heartbeat intervals that the Leader can tolerate when accepting Follower’s initial connection. When the length of 10 heartbeats (that is, tickTime) has been exceeded, the Leader has not received the follower’s return information, then it indicates that the follower connection has failed. The total length of time is 52000=10 seconds.
syncLimit=5
This configuration item identifies the length of the message sent between Leader and Follower, request and response time, the longest cannot exceed the length of tickTime, the total length of time is 52000= 10 seconds.
dataDir=/tmp/zookeeper
As the name implies, it is the directory where ZooKeeper saves data. It is used to store the in-memory database snapshot folder. At the same time, the myid file used for the cluster is also stored in this folder. By default, ZooKeeper also saves the log files for writing data in this directory. Note: A configuration file can only contain one dataDir, even if it is commented out.
clientPort=2181
This port is the port for the client to connect to the ZooKeeper server. ZooKeeper will listen to this port and accept the client’s access request.
maxClientCnxns=60
Maximum number of client connections, the default is 60.
autopurge.snapRetainCount=3
autopurge.purgeInterval=1
The client will generate unusual More logs, and ZooKeeper will also save the data in the memory as a snapshot, these data will not be automatically deleted, so there will be more and more such data in the disk. However, you can set these two parameters to let zookeeper automatically delete data. autopurge.purgeInterval is to set how many hours to clean up once. And autopurge.snapRetainCount is to set how many snapshots to keep, and the previous ones are deleted.
server.A=B: C: D: where A is a number, which means that this is the number server; B is the ip address of this server; C means that this server exchanges information with the Leader server in the cluster Port; D indicates that in case the Leader server in the cluster hangs up, a port is needed to re-elect and select a new leader, and this port is the port used to communicate with each other when the election is performed. If it is a pseudo-cluster configuration method, since B is the same, the communication port numbers of different Zookeeper instances cannot be the same, so different port numbers should be assigned to them.
1. Download the zookeeper software package
Go to the ZooKeeper official website link: [http://zookeeper.apache.org/] to download the software package.
2. After downloading, upload it to the /srv directory or other directories.
3. Decompress and move, as shown below:
4, Create data and log directories
mkdir -p /usr/local/zookeeper/zookeeperdata/{1,2,3}
mkdir -p /usr/local/zookeeper/zookeeperlogs/{1,2,3}
5. Create a file myid in a data directory, zookeeper according to the myid The value determines which server.
6. Modify the configuration File
8, check status