zookeeper集群搭建

Posted 用手踢球

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zookeeper集群搭建相关的知识,希望对你有一定的参考价值。

1上传三个zookeeper到三个服务器,服务器ip分别为192.168.199.71,192.168.199.72,192.168.199.73,因为zookeeper会实行投票选举机制,所以集群数最好为奇数

2zookeeper分别解压到/usr/local/zookeeper目录下

3在zookeeper/conf下,复制zoo_sample.cfg为zoo.cfg,并修改zoo.cfg配置文件

tickTime=2000
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/logs
server.0=192.168.199.71:2888:3888    
server.1=192.168.199.72:2888:3888     
server.2=192.168.199.73:2888:3888

4在zookeeper下,分别建立文件夹data和logs

5 192.168.199.71,192.168.199.72,192.168.199.73三个服务器,在data目录分别建立文件myid,并且里面内容分别为0,1,2,和配置文件的配置对应

6分别启动三个zookeeper bin/zkServer.sh start

7查看三个状态 bin/zkServer.sh status,会看其实一台服务器mode为leader,另外两台为follower

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

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


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

8关闭leader服务器,另外两台会有一台变为leader,而关闭的这台重新启动,会变成follower模式  

以上是关于zookeeper集群搭建的主要内容,如果未能解决你的问题,请参考以下文章

zookeeper集群搭建方式

Kafka + Zookeeper集群搭建

Zookeeper集群搭建

zookeeper--- 搭建zookeeper集群

zookeeper集群环境搭建(使用kafka的zookeeper搭建zk集群)

Hadoop详解——ZooKeeper详解,ZooKeeper伪分布搭建和集群搭建,Hadoop集群搭建,sqoop工具的使用