Zookeeper集群配置

参考:http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html#sc_RunningReplicatedZooKeeper

http://zookeeper.apache.org/doc/trunk/zookeeperAdmin.html#sc_zkMulitServerSetup

一、zookeeper集群中的每台服务器都在dataDir目录下添加文件myid

这里指定在/home/data/zookeeper下

 cd /home/data/zookeeper

 vi myid

 1#注释:这个写1——255间的数字,表示zookeeper服务器的id和zoo.cfg的server.id(例如:server.1) 对应

# cat myid #查看文件内容

二、修改conf/zoo.cfg文件

tickTime=2000
dataDir=/home/data/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.1.155:2888:3888
server.2=192.168.1.156:2888:3888
server.3=192.168.1.157:2888:3888

添加了集群的:

server.1=192.168.1.155:2888:3888
server.2=192.168.1.156:2888:3888
server.3=192.168.1.157:2888:3888

The new entry, initLimit is timeouts ZooKeeper uses to limit the length of time(次数) the ZooKeeper servers in quorum have to connect to a leader. The entry syncLimit limits how far out of date a server can be from a leader.

initLimit用于限制集群中的子集连接到leader的次数

With both of these timeouts, you specify the unit of time using tickTime. In this example, the timeout for initLimit is 5 ticks at 2000 milleseconds a tick, or 10 seconds.

tickTime表示连接服务器的单位,即2000豪秒连接一次。

The entries of the form server.X list the servers that make up the ZooKeeper service. When the server starts up, it knows which server it is by looking for the file myid in the data directory. That file has the contains the server number, in ASCII.

server.x 这里的x对应mypid文件中的内容

Finally, note the two port numbers after each server name: " 2888" and "3888". Peers use the former port to connect to other peers. Such a connection is necessary so that peers can communicate, for example, to agree upon the order of updates. More specifically, a ZooKeeper server uses this port to connect followers to the leader. When a new leader arises, a follower opens a TCP connection to the leader using this port. Because the default leader election also uses TCP, we currently require another port for leader election. This is the second port in the server entry.


For the ZooKeeper service to be active, there must be a majority of non-failing machines that can communicate with each other. To create a deployment that can tolerate the failure of F machines, you should count on deploying 2xF+1 machines. Thus, a deployment that consists of three machines can handle one failure, and a deployment of five machines can handle two failures. Note that a deployment of six machines can only handle two failures since three machines is not a majority. For this reason, ZooKeeper deployments are usually made up of an odd number of machines.


zookeeper集群可以容忍的故障机数量设为 F,则集群的总数量为: 2*F+1;

即集群的最小数量,最好为3


三、启动 zookeeper

bin/zkServer.sh .start;

然后查看zookeeper的主从状态:

bin/zkServer.sh status

JMX enabled by default

Using config: /home/tools/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: leader

四、zookeeper监控:

taokeeper, ZooKeeper-Monitor, a monitor for zookeeper in java

官方地址:

https://github.com/alibaba/taokeeper

http://jm-blog.aliapp.com/?p=1450





转载于:https://my.oschina.net/u/1045177/blog/411570

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值