zookeeper-linux集群搭建小结
注意事项:
1. 节点数遵循2n+1
2. 相应端口对外开放
3. 约定:各个节点的zoo.cfg内容完全一样(统一data和log目录)
如下:
# 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.
dataDir=/zoo/zookeeper/data
dataLogDir=/zoo/zookeeper/logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=192.168.1.1:2888:3888
server.2=192.168.1.2:2888:3888
server.3=192.168.1.3:2888:3888
4. 各个节点分别创建dataDir目录,在该目录下创建myid文件,文件里的数字内容,同当前节点在zoo.cfg中配置的server序号一致;
5.启动后,可用./zkServer.sh status 命令校验leader / follower
[zookeeper@centos bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /zoo/zookeeper/bin/../conf/zoo.cfg
Mode: leader