# 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=../zkData dataLogDir=../zkData/log # the port at which the clients will connect clientPort=2183 # 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 reconfigEnabled=true #server.1=127.0.0.1:2081:2780:2783:participant;2791 server.1=127.0.0.1:2887:3887 server.2=127.0.0.1:2888:3888 #server.3=127.0.0.1:2889:3889 admin.serverPort=8081
# 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=../zkData dataLogDir=../zkData/log # the port at which the clients will connect clientPort=2182 # 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 reconfigEnabled=true #server.1=127.0.0.1:2081:2780:2783:participant;2791 server.1=127.0.0.1:2887:3887 server.2=127.0.0.1:2888:3888 #server.3=127.0.0.1:2889:3889 admin.serverPort=8082
run servers
zkServer 分别启动两个 server
test
ok,没有啥问题
有意思的是,当我关掉一台 server 时,分别连接 2 个 server 的 client 都出现了异常
那么集群的高可用性、健壮性是如何体现的呢?
当我启动3台server时,如果我关闭其中1台,那么,对应的3个client,只有连接关闭那台server的client受到了影响,这是因为 zk server 具有fast fail特性,当挂掉的 server 数量不超过 server 总量的 1/2 时,不影响其提供服务