报错:WARN [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 2 at election address /x.x.x.x:3888

时间:2021-11-27 16:06:39

报错背景:

zookeeper安装完成之后,启动之后正常,但是查看log文件zookeeper.log时发现报错。

报错现象:

报错:WARN  [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 2 at election address /x.x.x.x:3888

-- ::, [myid:] - INFO  [WorkerSender[myid=]:QuorumPeer$QuorumServer@] - Resolved hostname: 192.168.52.27 to address: /192.168.52.27
-- ::, [myid:] - INFO [WorkerReceiver[myid=]:FastLeaderElection@] - Notification: (message format version), (n.leader), 0x1000000b2 (n.zxid), 0x1 (n.round), LOOKING (n.state), (n.sid), 0x6 (n.peerEpoch) LOOKING (my state)
-- ::, [myid:] - WARN [WorkerSender[myid=]:QuorumCnxManager@] - Cannot open channel to at election address /192.168.52.27:
java.net.ConnectException: 拒绝连接 (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:)
at java.net.Socket.connect(Socket.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:)
at java.lang.Thread.run(Thread.java:)
-- ::, [myid:] - INFO [WorkerSender[myid=]:QuorumPeer$QuorumServer@] - Resolved hostname: 192.168.52.27 to address: /192.168.52.27
-- ::, [myid:] - INFO [/192.168.52.28::QuorumCnxManager$Listener@] - Received connection request /192.168.52.27:
-- ::, [myid:] - INFO [WorkerReceiver[myid=]:FastLeaderElection@] - Notification: (message format version), (n.leader), 0x1000000b2 (n.zxid), 0x1 (n.round), LOOKING (n.state), (n.sid), 0x6 (n.peerEpoch) LOOKING (my state)
-- ::, [myid:] - INFO [WorkerReceiver[myid=]:FastLeaderElection@] - Notification: (message format version), (n.leader), 0x1000000b2 (n.zxid), 0x1 (n.round), LOOKING (n.state), (n.sid), 0x6 (n.peerEpoch) LOOKING (my state)

报错原因:

如果是刚启动zookeeper报出这个错误,然后不再不错,那就是正常现象。是由于有的节点启动,而有的节点还没有启动,这段时间已经启动的节点就会去努力寻找没有启动的节点,就会报出这样的错误。这是一种正常现象,无需多虑。

如果启动很长时间之后还在报错,可以尝试下面的饿解决方案。

报错解决:

修改每个节点的zoo.cfg文件中的相对应的server.x=0.0.0.0:2888:3888

报错:WARN  [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 2 at election address /x.x.x.x:3888

报错:WARN  [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 2 at election address /x.x.x.x:3888

报错:WARN  [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 2 at election address /x.x.x.x:3888

修改完成后重启zookeeper,报错消失。