Reputation: 33
I have four questions regarding zoo-keeper. Please give your inputs on this regard.
What is the command in zookeeper to make a leader voluntarily into a follower inside a cluster,which in-turn will make another follower machine in cluster to takeover a leader?
What is the procedure followed by zookeeper to do an election to form a leader inside cluster?
What is the command to check the cluster status in zookeeper, in turn I can say that, is there any command in zookeeper that cluster status for zoo-keeper is healthy and also the cluster formed successfully for zookeeper?
Upvotes: 2
Views: 9496
Reputation: 27487
Question 1) Zookeeper leader stepdown - good question, other than shutting the leader down and then brining it back up I'm not certain of any command to do that.
Question 2) Leader election: some discussion of that here:
Leader Activation Leader activation includes leader election. We currently have two leader election algorithms in ZooKeeper: LeaderElection and FastLeaderElection (AuthFastLeaderElection is a variant of FastLeaderElection that uses UDP and allows servers to perform a simple form of authentication to avoid IP spoofing). ZooKeeper messaging doesn't care about the exact method of electing a leader has long as the following holds:
The leader has seen the highest zxid of all the followers. A quorum of servers have committed to following the leader. Of these two requirements only the first, the highest zxid amoung the followers needs to hold for correct operation. The second requirement, a quorum of followers, just needs to hold with high probability. We are going to recheck the second requirement, so if a failure happens during or after the leader election and quorum is lost, we will recover by abandoning leader activation and running another election.
After leader election a single server will be designated as a leader and start waiting for followers to connect. The rest of the servers will try to connect to the leader. The leader will sync up with followers by sending any proposals they are missing, or if a follower is missing too many proposals, it will send a full snapshot of the state to the follower.
http://zookeeper.apache.org/doc/r3.3.2/zookeeperInternals.html#sc_leaderElection
Question 3) checking cluster status - you can try issuing one of the 4 letter commands at the client port, like this:
echo ruok | nc 127.0.0.1 5111
which will respond imok if all is well.
Full list of commands here: https://zookeeper.apache.org/doc/r3.4.8/zookeeperAdmin.html#sc_zkCommands
or run JMX: http://zookeeper.apache.org/doc/r3.3.1/zookeeperJMX.html
Upvotes: 2