解决ZooKeeper集群搭建 [myid:1] - WARN [QuorumPeer[myid=1]:QuorumCnxManager@685] - Cannot open channel

x33g5p2x  于2021-11-22 转载在 Zookeeper  
字(1.2k)|赞(0)|评价(0)|浏览(1024)

ZooKeeper集群搭建中出现错误:

[myid:1] - WARN  [QuorumPeer[myid=1](plain=0.0.0.0:2181)(secure=disabled):QuorumCnxManager@685] - Cannot open channel to 3 at election address /x.x.x.x:3883
java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
	at java.net.Socket.connect(Socket.java:606)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:656)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:713)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:741)
	at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:910)
	at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:1229)

问题分析:

一般出现此问题原因有:

  • 端口被占用
  • IP地址不是本机网卡

解决:

  • 换一个端口进行监听
  • 让服务器监听所有网卡
    在配置文件conf/zoo.cfg中添加
quorumListenOnAllIPs=true

本文仅作为本人学习使用,如有错误或不足欢迎指正!

相关文章