假设我有一个集合的Zookeeper,它可以启动并运行Apache Kafka(Confluent的发行版)。
已配置并启动3个实例(clientPorts:2181
,2182
和2183
),如下所示:
./bin/zookeeper-server-start etc/kafka/zookeeper.properties
./bin/zookeeper-server-start etc/kafka/zookeeper1.properties
./bin/zookeeper-server-start etc/kafka/zookeeper2.properties
在任何给定时间,我如何检查哪个Zookeeper实例是整体的领导者?
答案 0 :(得分:2)
有几种方法可以找到合奏的领导者。最简单的可能就是使用:
简单地询问Zookeeper实例echo stat | nc ZOOKEEPER_IP ZOOKEEPER PORT | grep Mode
将打印此实例是leader
,follower
还是standalone
。
这个page还展示了如何从Zookeeper的日志
中找到它答案 1 :(得分:1)
以下是这些命令和输出,用于检查3个节点动物园管理员群集中的 Leader 或 follower 。 当您尝试使用srvr时可能会出现错误,您将得到类似的错误。
[administrator @ centos-aes1 kafka_2.12-2.4.0] $ echo srvr | nc localhost 2181
srvr未执行,因为它不在白名单中。
然后,您必须将srvr列入白名单,或者尝试使用下面给出的下4个字母命令:-
The list of known four letter word commands is :
[{1936881266=srvr, 1937006964=stat, 2003003491=wchc, 1685417328=dump, 1668445044=crst, 1936880500=srst, 1701738089=envi, 1668247142=conf, -720899=telnet close, 2003003507=wchs, 2003003504=wchp, 1684632179=dirs, 1668247155=cons, 1835955314=mntr, 1769173615=isro, 1920298859=ruok, 1735683435=gtmk, 1937010027=stmk}]
您也可以将其用于更多信息。
############################# FirstNode ############ ##################
[administrator@centos-aes1 kafka_2.12-2.4.0]$ echo srvr | nc localhost 2181
Zookeeper version: 3.5.6-c11b7e26bc554b8523dc929761dd28808913f091, built on 10/08/2019 20:18 GMT
Latency min/avg/max: 0/0/0
Received: 34
Sent: 32
Connections: 1
Outstanding: 0
Zxid: 0x5000000b8
**Mode: follower**
Node count: 28
##############################第二节点############ ##################
[root@centos-aes2 administrator]# echo srvr | nc localhost 2181
Zookeeper version: 3.5.6-c11b7e26bc554b8523dc929761dd28808913f091, built on 10/08/2019 20:18 GMT
Latency min/avg/max: 0/0/6
Received: 10233
Sent: 10232
Connections: 4
Outstanding: 0
Zxid: 0x800000000
**Mode: leader**
Node count: 28
Proposal sizes last/min/max: -1/-1/-1
#############################第三节点############ ##################
[administrator@centos-aes3 ~]$ echo srvr | nc localhost 2181
Zookeeper version: 3.5.6-c11b7e26bc554b8523dc929761dd28808913f091, built on 10/08/2019 20:18 GMT
Latency min/avg/max: 0/0/0
Received: 32
Sent: 30
Connections: 1
Outstanding: 0
Zxid: 0x5000000b8
**Mode: follower**
Node count: 28