Zookeeper:已启动,但可能没有运行

时间:2018-03-10 09:46:47

标签: apache-zookeeper

我目前正在使用zookeeper作为东西,我确实很容易运行了几次。 但似乎我的集群节点昨天有一些网络连接问题,所以我重新启动系统。 当我跑: 的仓/ zkServer.sh : ,它说 STARTED 。 但是当我想获得状态时: zookeeper可能没有运行 如果我再次开始它说:   zookeeper已经使用pid = 123

运行

有什么问题吗?我怎样才能解决这个问题? 谢谢。

ps:这是我 start-foreground

时的日志
ZooKeeper JMX enabled by default
Using config: /home/mesto/zookeeper-3.4.10/bin/../conf/zoo.cfg
2018-03-11 12:47:51,908 [myid:] - INFO  [main:QuorumPeerConfig@134] -Reading configuration from: /home/mesto/zookeeper-3.4.10/bin/../conf/zoo.cfg
2018-03-11 12:47:51,920 [myid:] - INFO  [main:QuorumPeer$QuorumServer@167] - Resolved hostname: 11.0.0.1 to address: /11.0.0.1
2018-03-11 12:47:51,921 [myid:] - INFO  [main:QuorumPeer$QuorumServer@167] - Resolved hostname: 11.0.0.3 to address: /11.0.0.3
2018-03-11 12:47:51,921 [myid:] - INFO  [main:QuorumPeer$QuorumServer@167] - Resolved hostname: 11.0.0.2 to address: /11.0.0.2
2018-03-11 12:47:51,921 [myid:] - INFO  [main:QuorumPeerConfig@396] - Defaulting to majority quorums
2018-03-11 12:47:51,939 [myid:1] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2018-03-11 12:47:51,939 [myid:1] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2018-03-11 12:47:51,939 [myid:1] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2018-03-11 12:47:51,962 [myid:1] - INFO  [main:QuorumPeerMain@127] - Starting quorum peer
2018-03-11 12:47:51,969 [myid:1] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
2018-03-11 12:47:51,982 [myid:1] - INFO  [main:QuorumPeer@1134] - minSessionTimeout set to -1
2018-03-11 12:47:51,982 [myid:1] - INFO  [main:QuorumPeer@1145] - maxSessionTimeout set to -1
2018-03-11 12:47:51,982 [myid:1] - INFO  [main:QuorumPeer@1419] - QuorumPeer communication is not secured!
2018-03-11 12:47:51,982 [myid:1] - INFO  [main:QuorumPeer@1448] - quorum.cnxn.threads.size set to 20
2018-03-11 12:47:52,010 [myid:1] - INFO  [ListenerThread:QuorumCnxManager$Listener@739] - My election bind port: /11.0.0.1:3888
2018-03-11 12:47:52,016 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer@865] - LOOKING
2018-03-11 12:47:52,018 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@818] - New election. My id =  1, proposed zxid=0x0
2018-03-11 12:47:52,020 [myid:1] - INFO  [WorkerReceiver[myid=1]:FastLeaderElection@600] - Notification: 1 (message format version), 1 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING (n.state), 1 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state)
2018-03-11 12:47:57,026 [myid:1] - WARN  [WorkerSender[myid=1]:QuorumCnxManager@588] - Cannot open channel to 2 at election address /11.0.0.2:3888
java.net.SocketTimeoutException: connect timed out
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:745)
2018-03-11 12:47:57,030 [myid:1] - INFO  [WorkerSender[myid=1]:QuorumPeer$QuorumServer@167] - Resolved hostname: 11.0.0.2 to address: /11.0.0.2
2018-03-11 12:48:02,036 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@588] - Cannot open channel to 2 at election address /11.0.0.2:3888

1 个答案:

答案 0 :(得分:1)

Zookeeper正在运行,但由于某种原因,没有节点可以被选为领导者。 ./sbin/zkServer.sh status的输出不合适。

有一种方法可以确认,运行:

echo srvr |nc localhost 2181

您可能会看到如下结果:

This ZooKeeper instance is not currently serving requests

解决方案是启动另外两个节点,并检查选举是否完成。