Reputation: 5694
I would like to be able to programmatically (or use a a shell script) to list all the zookeeper bootstrap servers for each of my environments.
If i just know one of the bootstrap servers can I get a list of all of them?
Upvotes: 2
Views: 5270
Reputation: 511
Not sure if this helps directly, but I used the following to find a bootstrap server from a Kafka zookeeper:
zkCli.sh -server host:port
[zkCli prompt] ls /kafka
[..., brokers, ...]
[zkCli prompt] ls /kafka/brokers
[1, 2, 3, 4, 5]
[zkCli prompt] ls /kafka/brokers/1
[1]
[zkCli prompt] get /kafka/brokers/1
>> broker info<<
Upvotes: 0
Reputation: 3218
All active brokers are registered under /brokers/ids/[brokerId]
, you can query ZNode information via any ZK client(for example org.I0Itec.zkclient). All you need is zkQuorum address.
zkClient = new ZkClient(properties.getProperty("zkQuorum"), zkSessionTimeout, zkConnectionTimeout,
ZKStringSerializer$.MODULE$);
Kafka data structures in Zookeeper
Upvotes: 2