This ZooKeeper instance is not currently serving requests

zookeeper集群启动失败

这里不介绍安装步骤,下面是验证服务是否启动时的结果,主要异常是This ZooKeeper instance is not currently serving requests

[root@localhost bin]# telnet 127.0.0.1 2181
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stat
This ZooKeeper instance is not currently serving requests
Connection closed by foreign host.

报这个异常的原因就是集群没有选出来leader,当集群里的结点只剩下一台,或者不足半数时,就会出现这个错误提示。
可是为什么没有选出来leader呢,查了一下最终是因为网络不通,那就防火墙开放端口2181,结果还是不行。但是当我把防火墙完全关闭的时候,重启zookeeper集群验证却通过了。这时我想肯定是还有端口没有开放,查我的配置文件如下

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=5
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=2
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zookeeper-3.4.9/data
# the port at which the clients will connect
clientPort=2181

server.1=192.168.160.130:2888:3888
server.2=192.168.160.131:2888:3888
server.3=192.168.160.132:2888:3888

# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

zookeeper配置中除了2181端口还有2888 和3888
把这三个端口都开放,然后重加载firewall防火墙配置,重启zookeeper果然集群成功启动

firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --zone=public --add-port=2888/tcp --permanent
firewall-cmd --zone=public --add-port=3888/tcp --permanent
firewall-cmd --reload
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值