server 1: [root@wx03 bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /zookeeper/server1/bin/../conf/zoo.cfg Mode: follower server 2: [root@wx03 bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /zookeeper/server2/bin/../conf/zoo.cfg Mode: leader server 3: [root@wx03 bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /zookeeper/server3/bin/../conf/zoo.cfg Mode: follower 关闭server 1 follower: 此时server 1的状态: [root@wx03 bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /zookeeper/server1/bin/../conf/zoo.cfg Error contacting service. It is probably not running. 关闭leader: 此时server 3称为leader: [root@wx03 zookeeper]# cd server3 [root@wx03 server3]# cd bin/ [root@wx03 bin]# ./zk zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh [root@wx03 bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /zookeeper/server3/bin/../conf/zoo.cfg Mode: leader 发现zk 切换有时候会取不到数据: zjtest7-redis:/root/zk# perl test_zk.pl 192.168.32.6 @arr2 is 1 aaabbb 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe 2 cccddeqe zjtest7-redis:/root/zk# perl test_zk.pl zjtest7-redis:/root/zk# 原因: 你给出的zookeeper列表里哪些主机已经死了.你链接的时候会失效是很正常的. 如果不是长连接,需要把停掉的server 节点,踢掉