1. Zoo.cfg configuration
By looking at the previous article, I believe we have built up three virtual machines on the three virtual machines
su zookeeper
, switch to the zookeeper accounts,
modify the three virtual machine /usr/local/zookeeper-3.4.14/conf/zoo.cfg
file, add the following configuration:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# zk 数据目录
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# 配置每个示例的IP
server.1=192.168.56.101:2888:3888
server.2=192.168.56.102:2888:3888
server.3=192.168.56.103:2888:3888
The role of each port number:
2181: the port that provides services to the client,
2888: the port used for communication in the cluster,
3888: the port used by the leader selected in the cluster.
You can use the command to transfer the zookeeper-3.4.14 application directory to the other two instances:
scp -r zookeeper 192.168.56.102:`pwd`
scp -r zookeeper 192.168.56.103:`pwd`
2. myid
Enter the zookeeper data directory of the three virtual machines:, /tmp/zookeeper
respectively execute:
echo 1 > myid
echo 2 > myid
echo 3 > myid
Corresponding to the configuration in zoo.cfg server.1、server.2、server.3
.
3. Turn off the firewall
In order to facilitate communication between clusters, turn off the firewall directly:
systemctl stop firewalld.service
Last
Start zookeeper of each virtual machine in turn:
./zkServer.sh start
Let 's take a look at the status of the three examples: just ask if you are surprised!