Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check which zookeeper instance is the leader within an ensemble

Assume that I have an ensemble Zookeeper which is up and running to facilitate and serve Apache Kafka (Confluent's distribution).

3 instances (clientPorts: 2181, 2182 and 2183) have been configured and started as shown below:

./bin/zookeeper-server-start etc/kafka/zookeeper.properties
./bin/zookeeper-server-start etc/kafka/zookeeper1.properties
./bin/zookeeper-server-start etc/kafka/zookeeper2.properties

At any given time, how can I check which Zookeeper instance is the leader of the ensemble?

like image 269
Giorgos Myrianthous Avatar asked Nov 15 '25 10:11

Giorgos Myrianthous


1 Answers

There are a few ways to find the leader of an ensemble. The easiest is probably to simply ask the Zookeeper instances using:

echo stat | nc ZOOKEEPER_IP ZOOKEEPER PORT | grep Mode

that will print whether this instance is a leader, follower or standalone.

This page also shows how to find this out from Zookeeper's logs

like image 181
Mickael Maison Avatar answered Nov 17 '25 08:11

Mickael Maison



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!