加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 需要发出什么命令来检查ZooKeeper服务器是领导者还是追

发布时间:2020-12-13 18:34:28 所属栏目:Linux 来源:网络整理
导读:已创建由三个ZooKeeper服务器组成的ZooKeeper仲裁. 位于所有三个ZooKeeper服务器上的zoo.cfg如下所示: maxClientCnxns=50# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial# synchronization phase can takei
已创建由三个ZooKeeper服务器组成的ZooKeeper仲裁.

位于所有三个ZooKeeper服务器上的zoo.cfg如下所示:

maxClientCnxns=50
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/var/lib/zookeeper
# the port at which the clients will connect
clientPort=2181

server.1=<ip-address-1>:2888:3888
server.2=<ip-address-2>:2888:3888
server.3=<ip-address-3>:2888:3888

分析

很明显,三个ZooKeeper服务器中的一个将成为领导者和其他粉丝.如果Leader ZooKeeper服务器已关闭,则Leader选举将重新开始.目的是检查Leader服务器是否已关闭,另一个ZooKeeper服务器是否会成为Leader.

需要发出什么命令来检查ZooKeeper服务器是领导者还是追随者?

解决方法

可以使用netcat包中包含的nc命令检查ZooKeeper服务器是否是领导者或关注者:
echo stat | nc localhost 2181 | grep Mode
echo srvr | nc localhost 2181 | grep Mode #(From 3.3.0 onwards)

如果ZooKeeper服务器是领导者,那么命令将返回:模式:领导者和否则:模式:关注者

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读