Four, zookeeper cluster structures

Zookeeper Installation:
Download the installation package:
https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.14/
with the 3.5 version of the service to get up, I do not know why

First, the incoming packets within the server, extracting
the tar-xvf Apache ZooKeeper-3.5.6.tar.gz -C / usr /
CD / usr && Music Videos Apache-3.5.6-ZooKeeper / rename ZooKeeper #

cd /usr/zookeeper/conf
cp zoo_sample.cfg zoo.cfg

Such a good zookeeper node on the installation finished

Second, the configuration of the cluster:
tickTime = 2000 #tick is the heartbeat, every two seconds to detect a heartbeat
initLimit = 10 up to ten tick, that is, 20s, tick is a unit, leader and follower started when the maximum time communications over 20s considers Rom
syncLimit = 5 sync longest five tick, the communication time after 10s, start the cluster
above three do not change
dataDir = / usr / ZooKeeper / zkData # store data directory
clientPort = 2181 client port , can be changed not changed


以下是需要添加的配置:集群有哪些机器
Server.**2**=server_ip:2888:3888 ** #2888是各节点之间通信的端口数据副本,3888是选举端口号**
Server.**3**=server_ip:2888:3888  ** # 2、 3、 4这三个数没要求,只要不一样就行,是每台机器的id,要记住**
Server.**4**=server_ip:2888:3888

I Environmental
Server.4 = 192.168.50.134: 2888: 3888
Server.9 = 192.168.50.139: 2888: 3888

Third, create After configuring the directory, and create files in this directory zkData myid in
mkdir / usr / ZooKeeper / zkData
Touch myid # This file name can not be changed, that is myid , created under dataDir specified directory,
I now 192.168.50.134 on this machine, because to id this machine is 4, so I want 4 myid wrote this document inside
echo 4> myid this to remember

Fourth, specify the directory to store the log:

cd /usr/zookeeper/bin
vim zkEnv.sh
if [ "x${ZOO_LOG_DIR}" = "x" ]  
then
    ZOO_LOG_DIR="/usr/zookeeper/logs"   #需要手动指定,不能让日志乱放
fi

mkdir /usr/zookeeper/logs

Above on the configuration finished, and then after zookeeper this directory, copy it to another machine, change it myid contents of the file on the line.

scp -p /usr/zookeeper  192.16830.139:/usr

usr / zookeeper / bin / zkServer.sh start to start more than half of the total number of clusters to display election leader and follower
/usr/zookeeper/bin/zkServer.sh Status # displays leader and follower

After we configured for distribution

Guess you like

Origin blog.51cto.com/13930997/2454371