更新时间:2023-11-28 09:06:40
必须为所有Kafka经纪人分配 broker.id
。启动时,代理将在Zookeeper中创建一个短暂的节点,路径为 / broker / ids / $ id
。由于节点是短暂的,所以一旦代理断开连接,它将被移除,例如,通过关闭。
All Kafka brokers must be assigned a broker.id
. On startup a broker will create an ephemeral node in Zookeeper with a path of /broker/ids/$id
. As the node is ephemeral it will be removed as soon as the broker disconnects, e.g. by shutting down.
您可以查看短暂的代理节点列表,如下所示:
You can view the list of the ephemeral broker nodes like so:
echo dump | nc localhost 2181 | grep brokers
ZooKeeper客户端接口公开了许多命令; dump
列出集群的所有会话和临时节点。
The ZooKeeper client interface exposes a number of commands; dump
lists all the sessions and ephemeral nodes for the cluster.
注意,上面假设:
上的默认端口( 2181
)上运行ZooKeeper localhost
,而 localhost
是群集的领导者 zookeeper .connect
Kafka config没有为你的Kafka集群指定一个chroot env,即它只是 host:port
而不是 host :port / path
2181
) on localhost
, and that localhost
is the leader for the clusterzookeeper.connect
Kafka config doesn't specify a chroot env for your Kafka cluster i.e. it's just host:port
and not host:port/path