报错背景:
zookeeper安装完成之后,启动之后正常,但是查看log文件zookeeper.log时发现报错。
报错现象:
2019-05-22 11:40:38,469 [myid:1] - INFO [WorkerSender[myid=1]:QuorumPeer$QuorumServer@185] - Resolved hostname: 192.168.52.27 to address: /192.168.52.27 2019-05-22 11:40:38,470 [myid:1] - INFO [WorkerReceiver[myid=1]:FastLeaderElection@595] - Notification: 1 (message format version), 3 (n.leader), 0x1000000b2 (n.zxid), 0x1 (n.round), LOOKING (n.state), 1 (n.sid), 0x6 (n.peerEpoch) LOOKING (my state) 2019-05-22 11:40:38,470 [myid:1] - WARN [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 2 at election address /192.168.52.27:3888 java.net.ConnectException: 拒绝连接 (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:558) at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:534) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:454) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:435) at java.lang.Thread.run(Thread.java:748) 2019-05-22 11:40:38,470 [myid:1] - INFO [WorkerSender[myid=1]:QuorumPeer$QuorumServer@185] - Resolved hostname: 192.168.52.27 to address: /192.168.52.27 2019-05-22 11:40:38,504 [myid:1] - INFO [/192.168.52.28:3888:QuorumCnxManager$Listener@743] - Received connection request /192.168.52.27:56020 2019-05-22 11:40:38,508 [myid:1] - INFO [WorkerReceiver[myid=1]:FastLeaderElection@595] - Notification: 1 (message format version), 2 (n.leader), 0x1000000b2 (n.zxid), 0x1 (n.round), LOOKING (n.state), 2 (n.sid), 0x6 (n.peerEpoch) LOOKING (my state) 2019-05-22 11:40:38,514 [myid:1] - INFO [WorkerReceiver[myid=1]:FastLeaderElection@595] - Notification: 1 (message format version), 3 (n.leader), 0x1000000b2 (n.zxid), 0x1 (n.round), LOOKING (n.state), 2 (n.sid), 0x6 (n.peerEpoch) LOOKING (my state)
报错原因:
如果是刚启动zookeeper报出这个错误,然后不再不错,那就是正常现象。是由于有的节点启动,而有的节点还没有启动,这段时间已经启动的节点就会去努力寻找没有启动的节点,就会报出这样的错误。这是一种正常现象,无需多虑。
如果启动很长时间之后还在报错,可以尝试下面的饿解决方案。
报错解决:
修改每个节点的zoo.cfg文件中的相对应的server.x=0.0.0.0:2888:3888
修改完成后重启zookeeper,报错消失。