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

linux – 需要发出什么命令来检查ZooKeeper服务器是领导者还是追随者?,第1张

概述已创建由三个ZooKeeper服务器组成的ZooKeeper仲裁. 位于所有三个ZooKeeper服务器上的zoo.cfg如下所示: maxClientCnxns=50# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial# synchronization ph 已创建由三个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 takeinitlimit=10# The number of ticks that can pass between# sending a request and getting an ackNowledgementsynclimit=5# the directory where the snapshot is stored.dataDir=/var/lib/zookeeper# the port at which the clIEnts will connectclIEntPort=2181server.1=<ip-address-1>:2888:3888server.2=<ip-address-2>:2888:3888server.3=<ip-address-3>:2888:3888

分析

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

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

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

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

总结

以上是内存溢出为你收集整理的linux – 需要发出什么命令来检查ZooKeeper服务器是领导者还是追随者?全部内容,希望文章能够帮你解决linux – 需要发出什么命令来检查ZooKeeper服务器是领导者还是追随者?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1045241.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存