Get the App
SLTechnology News&Howtos  ›  Servers  › 

Fourth, the construction of zookeeper cluster.

Shulou Source: shulou.com Published: 2022-06-02 15:44:06 09月12日 Update

Zookeeper installation:

Download the installation package:

Https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.14/

I can't get up with the 3.5 service. I don't know why.

First, transfer the package to the server and decompress it

Tar xvf apache-zookeeper-3.5.6.tar.gz-C / usr/

Cd / usr & & mv apache-zookeeper-3.5.6/ zookeeper # renamed

Cd / usr/zookeeper/conf

Cp zoo_sample.cfg zoo.cfg

Okay, such a zookeeper node will be installed.

2. Configuration of the cluster:

TickTime=2000 # tick is the heartbeat, which is detected every 2 seconds.

There are no more than ten tick in initLimit=10, that is, the 20s tick is the unit. The maximum time when leader and follower start to communicate is considered to be out of touch after 20s.

The maximum synchronization time of syncLimit=5 is 5 tick,10s, and the communication time after cluster startup

The above three need not be changed.

DataDir=/usr/zookeeper/zkData # the directory where the data is stored

ClientPort=2181 client port, which can be changed or not

The following is the configuration that needs to be added: which machines in the cluster Server.**2**=server_ip:2888:3888 * * # 2888 is the copy of port data for communication between nodes, and 3888 is the election port number * * Server.**3**=server_ip:2888:3888 * # 2, 3, 4, which are not required, as long as they are different. It is the id of each machine. Remember * * Server.**4**=server_ip:2888:3888.

My environment

Server.4=192.168.50.134:2888:3888

Server.9=192.168.50.139:2888:3888

Third, create a directory after configuration, and create the file myid in the directory zkData

Mkdir / usr/zookeeper/zkData

The file name touch myid # cannot be changed, that is, myid, created in the directory specified by dataDir

I am now on the 192.168.50.134 machine, because the id for this machine is 4, so I want to write 4 into the myid file.

Remember that echo 4 > myid

4. Specify the directory where the log is stored:

Cd / usr/zookeeper/binvim zkEnv.shif ["x ${ZOO_LOG_DIR}" = "x"] then ZOO_LOG_DIR= "/ usr/zookeeper/logs" # needs to be specified manually, and fimkdir / usr/zookeeper/logs cannot be misplaced in logs.

The above configuration is complete, and then copy the zookeeper directory to another machine, and change the contents of the myid file.

Scp-p / usr/zookeeper 192.16830.139:/usr

Usr/zookeeper/bin/zkServer.sh start needs to start more than half of the total number of clusters to display elective leader and follower.

/ usr/zookeeper/bin/zkServer.sh status # shows leader and follower

After we distribute the configured ones,

Tags: Directory machine configuration cluster file that is time communication data log port node service election maximum longest but no three no number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Microsoft Shulou Technology NVidia vpn