解决zookeeper集群搭建 [myid:1] - WARN [WorkerSender[myid=1]:QuorumCnxManager@588] - Cannot open channel

zookeeper集群搭建 [myid:1] - WARN [WorkerSender[myid=1]:QuorumCnxManager@588] - Cannot open channel to 3 at election

  • 错误提示
    之前进行集群搭建遇到了一些问题,记录一下
 [myid:1] - WARN  [WorkerSender[myid=1]:QuorumCnxManager@588] - Cannot open channel to 3 at election address /127.0.0.1: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: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)
  • 原因分析
    查看log发现如下信息
2019-01-29 00:20:14,794 [myid:1] - ERROR [/127.0.0.1:3888:QuorumCnxManager$Listener@763] - Exception while listening
java.net.BindException: Bind failed
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
    at java.net.ServerSocket.bind(ServerSocket.java:375)
    at java.net.ServerSocket.bind(ServerSocket.java:329)

查阅了一些资料,原因一般有:

  1. 端口被占用
  2. ip地址不是本机网卡
  • 解决方案
  1. 如果是端口被占用,换一个端口监听即可
  2. 如果是原因2.我们需要让服务器监听0.0.0.0的ip(所有网卡)

在conf中的zoo.cfg配置文件中添加

quorumListenOnAllIPs=true

就能解决该问题啦~

你可能感兴趣的:(Zookeeper)