How to list all available Kafka brokers in a cluster?

后端 未结 9 1224
甜味超标
甜味超标 2020-12-22 23:50

I am writing a shell script to monitor kafka brokers.

I have gone through some links and found that if ZooKeeper contains a list of brokers, and if, in this list, th

9条回答
  •  长情又很酷
    2020-12-23 00:17

    Alternate way using Zk-Client:

    If you do not prefer to pass arguments to ./zookeeper-shell.sh and want to see the broker details from Zookeeper CLI, you need to install standalone Zookeeper (As traditional Kafka do not comes up with Jline JAR).

    Once you install(unzip) the standalone Zookeeper,then:

    • Run the Zookeeper CLI:
      $ zookeeper/bin/zkCli.sh -server localhost:2181 #Make sure your Broker is already running

    • If it is successful, you can see the Zk client running as:

    WATCHER::

    WatchedEvent state:SyncConnected type:None path:null
    [zk: localhost:2181(CONNECTED) 0]
    
    • From here you can explore the broker details using various commands:

    $ ls /brokers/ids # Gives the list of active brokers
    $ ls /brokers/topics #Gives the list of topics
    $ get /brokers/ids/0 #Gives more detailed information of the broker id '0'

提交回复
热议问题