Zookeeper启动成功,但无法查看status

版权声明: https://blog.csdn.net/tiankong_12345/article/details/80332886

安装好zookeeper-3.4.10,顺利启动:

[root@node228 bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

jps也可以看到进程:

[root@node228 bin]# jps
2788 QuorumPeerMain
2917 Jps

查看zookeeper状态:出错了!!!

[root@node228 bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper-3.4.10/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.

查看/bin目录下的zookeeper.out日志:

2018-05-16 16:14:35,387 [myid:1] - WARN  [WorkerSender[myid=1]:QuorumCnxManager@588] - Cannot open channel to 2 at election address slave/192.168.255.129:3888
java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:562)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:538)
	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:452)
	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:433)
	at java.lang.Thread.run(Thread.java:748)

排除所有的配置问题后,还有出现,这是为啥呢?

那是因为只有这个节点的进程启动了,其他节点的进程还没有启动,这个节点的进程无法与其他节点进行交互,更无法选出leader和follwer,所以这个节点不知道自己到底是leader还是follwer,当然也就显示不了status了。

开启其他节点进程:

[root@node224 bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@node224 bin]# jps
4987 QuorumPeerMain
5023 Jps
[root@node224 bin]# 

再查看两个节点status:

[root@node228 bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower
[root@node228 bin]# 
[root@node224 bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: leader
[root@node224 bin]# 

哈哈,成功啦!!!

如果早点看懂原理,也就不用花这么长时间做测试了敲打


阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页