简体   繁体   中英

Kafka List all partition with no leader

In my kafka Cluster there are more than 2k topics and each topic has 5 partitions. I want list only that partitions which has no leader.

I can go can check for each topic using the below syntax:

kafka-topics.sh --describe --topic <topic_name> --zookeeper <zookeeper_ip>:port

But the problem is there are 2k+ topics, can't be done manually. I can also write a script to loop over each topic and get the partition with no leader. But i am interested in some efficient way to get the information.

Using kafka-topics.sh you can specify the --unavailable-partitions flag to only list partitions that currently don't have a leader and hence cannot be used by Consumers or Producers.

For example:

kafka-topics.sh --describe --unavailable-partitions --zookeeper <zookeeper_ip>:port

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM