Reputation: 2590
we are using Kafka version - 2.7.1
. cluster includes 5 Kafka machines on Linux RHEL 7.6
version
in order to find the brokers ids number , we can ask the zookeeper server as the following
/usr/bin/zookeeper-shell ZOO_SERVER:2181 <<< "ls /brokers/ids"
Connecting to ZOO_SERVER:2181
Welcome to ZooKeeper!
JLine support is disabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[1001, 1002, 1003, 1004, 1005]
so we know from above that brokers ids are - 1001, 1002, 1003, 1004, 1005
the question that I want to ask now:
how to know the Kafka machines names that equivalent brokers id's numbers?
I know that kafka01 is broker id 1001 and kafka02 is broker id 1002 , and so on , and this we can verified from meta.properties
file on which broker!
example
more meta.properties
#
#Mon Jun 21 10:41:58 UTC 2021
cluster.id=SZtPtVDBS1eTZsPRwhmnpg
version=0
broker.id=1004
** but we not want to perform ssh connection to each Kafka broker/s ( kafka01-05 ) and verify the file meta.properties
So I want to know if we can use some Kafka cli that show exactly the Kafka names
that are relevant for the brokers id's
for example , expected results ( below are only example to what we want to get )
1001 --> kafka01
1002 --> kafka02
1003 --> kafka03
1004 --> kafka04
1004 --> kafka04
Upvotes: 0
Views: 780
Reputation: 1821
You can get the endpoint name by the following zookeeper command
zookeeper-shell.sh [ZK_IP] get /brokers/ids/1001
In relation to your other question by calling zookeeper-shell.sh twice, we can get directly the broker name that is the active controller, instead of the broker id.
zookeeper-shell.sh [ZK_IP] get /brokers/ids/$(zookeeper-shell.sh [ZK_IP] get /controller|tail -1|jq .brokerid)|tail -1|jq .endpoints[]
Upvotes: 1