分布式服务框架 Zookeeper集群

zoo_sample.cfg文件改为zoo.cfghtml

# 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=/root/zkcluster/3001/data
dataLogDir=/root/zkcluster/3001/logs
# the port at which the clients will connect
clientPort=3001
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=6
#
# 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.161.134:2888:3888
server.2=192.168.161.135:2889:3889
server.3=192.168.161.136:2890:3890

server.A=B:C:D:其中 A 是一个数字,表示这个是第几号服务器;B 是这个服务器的 ip 地址;C 表示这个服务器与集群中的 Leader 服务器交换信息的端口;D 表示万一集群中的 Leader 服务器挂了,须要一个端口来从新进行选举,选出一个新的 Leader,而这个端口就是用来执行选举时服务器相互通讯的端口。apache

能够用命令看下哪一个server是leader,哪些是follower服务器

[root@localhost bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/zkcluster/3001/bin/../conf/zoo.cfg
Mode: follower

[root@localhost bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/zkcluster/3002/bin/../conf/zoo.cfg
Mode: leader 

[root@localhost bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/zkcluster/3003/bin/../conf/zoo.cfg
Mode: follower
相关文章
相关标签/搜索