Tips: 本文创建于2015年12月4日,已超过 2 年,内容或图片可能已经失效!

centos安装zookeeper集群

基于centos安装zookeeper(非集群)

拷贝一份zookeeper文件夹到三台机器上

通用的zoo.cfg为

# 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.  
# the port at which the clients will connect  
dataDir=/usr/local/zookeeper-3.3.6/ZooData/data  
dataLogDir=/usr/local/zookeeper-3.3.6/ZooData/logs  
clientPort=52181  
server.1=192.168.2.11:2888:38888  
server.2=192.168.2.12:2888:38888  
server.3=192.168.2.13:2888:38888 

修改myid,路径

zookeeper-3.3.6/ZooData/data/myid  

内容分别为1 2 3

测试

[[email protected] zookeeper-3.3.6]# bin/zkServer.sh status  
JMX enabled by default  
  
Using config: /usr/local/zookeeper-3.3.6/bin/../conf/zoo.cfg  
Mode: follower  

三台机器,有一台mode为leader,停止leader那台,会重新匹配一个leader,即成功