A ZooKeeper Quorum consisting of three ZooKeeper servers has been created.

The zoo.cfg located on all three ZooKeeper servers looks as follows:

# The number of milliseconds of each tick
# The number of ticks that the initial
# synchronization phase can take
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
# the directory where the snapshot is stored.
# the port at which the clients will connect



It is clear that one of the three ZooKeeper servers will become the Leader and the others Followers. If the Leader ZooKeeper server has been shutdown the Leader election will start again. The aim is to check if another ZooKeeper server will become the Leader if the Leader server has been shut down.


What command needs to be issued to check whether a ZooKeeper server is a Leader or a Follower?


It is possible to check whether a ZooKeeper server is a leader or follower using the nc command that is included in the netcat package:

echo stat | nc localhost 2181 | grep Mode
echo srvr | nc localhost 2181 | grep Mode #(From 3.3.0 onwards)

If the ZooKeeper server is a leader then the command will return: Mode: leader and otherwise: Mode: follower

  • 2
    and standalone – zinking Jan 4 '16 at 9:23
  • @bsd , is there any way to find the nodes in zookeeper cluster ?? – murarisumit Sep 6 '16 at 6:10
  • 2
    @sumit That probably needs its own SO question, but one way is to simply read the zoo.cfg file. – Jose Leon Dec 9 '16 at 14:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.