zookeeper集群搭建问题

2016-10-09 22:36:38,628 [myid:3] - INFO [main:QuorumPeer@1005] - initLimit set to 10
2016-10-09 22:36:38,646 [myid:3] - INFO [Thread-1:QuorumCnxManager$Listener@504] - My election bind port: /123.207.11.*:3883
2016-10-09 22:36:38,647 [myid:3] - ERROR [/123.207.11.*:3883:QuorumCnxManager$Listener@517] - Exception while listening
java.net.BindException: Cannot assign requested address
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:330)
at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:507)
2016-10-09 22:36:38,654 [myid:3] - INFO [QuorumPeer[myid=3]/0.0.0.0:2183:QuorumPeer@714] - LOOKING
2016-10-09 22:36:38,656 [myid:3] - INFO [QuorumPeer[myid=3]/0.0.0.0:2183:FastLeaderElection@815] - New election. My id = 3, proposed zxid=0x0
2016-10-09 22:36:38,663 [myid:3] - WARN [WorkerSender[myid=3]:QuorumCnxManager@382] - Cannot open channel to 1 at election address /123.207.18.*:3881
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:368)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:341)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:449)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:430)
at java.lang.Thread.run(Thread.java:745)
2016-10-09 22:36:38,667 [myid:3] - WARN [WorkerSender[myid=3]:QuorumCnxManager@382] - Cannot open channel to 2 at election address /119.29.130.*:3882
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:368)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:341)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:449)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:430)
at java.lang.Thread.run(Thread.java:745)
2016-10-09 22:36:38,668 [myid:3] - INFO [WorkerReceiver[myid=3]:FastLeaderElection@597] - Notification: 1 (message format version), 3 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING (n.state), 3 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state)
2016-10-09 22:36:38,870 [myid:3] - WARN [QuorumPeer[myid=3]/0.0.0.0:2183:QuorumCnxManager@382] - Cannot open channel to 2 at election address /119.29.*3882
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:368)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:402)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:840)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:762)
2016-10-09 22:36:38,871 [myid:3] - WARN [QuorumPeer[myid=3]/0.0.0.0:2183:QuorumCnxManager@382] - Cannot open channel to 1 at election address /123.207.*:3881
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:368)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:402)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:840)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:762)
2016-10-09 22:36:38,872 [myid:3] - INFO [QuorumPeer[myid=3]/0.0.0.0:2183:FastLeaderElection@849] - Notification time out: 400
2016-10-09 22:36:39,273 [myid:3] - WARN [QuorumPeer[myid=3]/0.0.0.0:2183:QuorumCnxManager@382] - Cannot open channel to 2 at election address /119.29.*:3882
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:368)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:402)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:840)

            这到底是什么原因


            我的zoo.cfg是
            server.1=123.207.18.*:2881:3881
            server.2=119.29.130.*:2882:3882
            server.3=123.207.11.*2883:3883

            myid有配置,防火墙关闭了,我的服务器是真实的服务器,腾讯云上的服务器。
            腾讯云安全组也配置了。为什么一直报错。难道是腾讯云服务器的问题,有没有
            办法解决?求解

8个回答

我自己解决了,服务器上不能填外网地址,要填内网地址

JustClimbing
nebo 你好。请问你知道为什么吗。
2 年多之前 回复

对应的地址,端口是否被占用了。

端口没有被占用,我检查了,确定没有被占用。一楼的办法我也早就试过,也没有用。补充一下,我用的是centos7

有多种可能:
有说这个异常可以忽略,原因是还有节点没有启动zookeeper,全部启动之后,自然就不会出异常了。由于zookeeper集群启动的时候,每个结点都试图去连接集群中的其它结点,先启动的肯定连不上后面还没启动的,所以上面日志前面部分的异常是可以忽略的。通过后面部分可以看到,集群在选出一个leader后,最后稳定了。

或者是
最初使用standalone模式时放pid的目录与后面使用集群模式的路径不同,导致重启时没能kill掉旧的zookeeper。只需手工kill -9 pid即可成功了。

再不行看看 http://blog.csdn.net/everl_1/article/details/52253513

你说的方式我试过了,这个异常不能忽略,因为我使用status查看,zookeeper是没启动的。第二张方法我也试过,手动kill也没有用

我的zoo.cfg是
server.1=10.5.24.*:2888:3888
server.2=10.16.8.*:2888:3888
server.3=10.16.8.*:2888:3888
我的情况是:status查看的时候显示未启动,但jps查看,发现一斤成功启动了,网上的四种方法都试过,还是一样,从节点查看日志是cannot open channel 3 at election address/10.16.8.*:3888.
两个从节点总是有一个没有办法status查看成功启动,我也试了换掉两个从节点中的一个端口,但还是会连接2888和3888端口,请问这都可能是什么原因呢?

谢谢博主,已解决问题。错误原因是
server.1=(错误前这里填写的外网地址).*:2888:3888
而我是个伪集群(单服务器,多服务,多端口)
所以正确写法应该是
server.1=内网(私有)IP.通信端口.选举端口

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐