我的问题是,在我配置的三台集群中就一台启动不起来,但是原来我的是三台都启动成功,最近就是这一台启动不起来,查看日志信息就是包这个错误。
2019-08-24 20:02:13,041 [myid:0] - WARN [WorkerSender[myid=0]:QuorumCnxManager@584] - Cannot open channel to 1 at election address zj02/192.168.8.131: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-08-24 20:02:13,159 [myid:0] - INFO [WorkerSender[myid=0]:QuorumPeer$QuorumServer@184] - Resolved hostname: zj02 to address: zj02/192.168.8.131
2019-08-24 20:02:13,044 [myid:0] - INFO [Thread-1:NIOServerCnxn@1040] - Closed socket connection for client /127.0.0.1:41334 (no session established for client)
2019-08-24 20:02:13,041 [myid:0] - INFO [WorkerReceiver[myid=0]:FastLeaderElection@595] - Notification: 1 (message format version), 0 (n.leader), 0xf0000004e (n.zxid), 0x1 (n.round), LOOKING (n.state), 0 (n.sid), 0x12 (n.peerEpoch) LOOKING (my state)
2019-08-24 20:02:13,162 [myid:0] - WARN [WorkerSender[myid=0]:QuorumCnxManager@584] - Cannot open channel to 2 at election address zj03/192.168.8.132:3888
java.net.ConnectException: 拒绝连接 (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
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-08-24 20:02:13,167 [myid:0] - INFO [WorkerSender[myid=0]:QuorumPeer$QuorumServer@184] - Resolved hostname: zj03 to address: zj03/192.168.8.132
2019-08-24 20:02:13,368 [myid:0] - WARN [QuorumPeer[myid=0]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@584] - Cannot open channel to 1 at election address zj02/192.168.8.131: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.connectAll(QuorumCnxManager.java:610)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:838)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:957)
2019-08-24 20:02:13,369 [myid:0] - INFO [QuorumPeer[myid=0]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@184] - Resolved hostname: zj02 to address: zj02/192.168.8.131
2019-08-24 20:02:13,369 [myid:0] - WARN [QuorumPeer[myid=0]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@584] - Cannot open channel to 2 at election address zj03/192.168.8.132: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.connectAll(QuorumCnxManager.java:610)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:838)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:957)
一般看见这个问题,我们首先想到的是配置文件的问题,但是如果我们原来可以正常运行,再次运行的时候出现这个问题,先查看自己的IP信息与我们配置的主机映射是否对应,不对应修改过来重新启动。一般大部分都是这个问题。如果第一次运行,先查看一下自己的zoo.cfg文件是否配置正确,我的配置信息如下:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/apps/zookeeper/tmp
clientPort=2181
server.0=zj01:2888:3888
server.1=zj02:2888:3888
server.2=zj03:2888:3888
再检查自己的myid标识符是否与配置信息一致,不一致修改过重新启动服务。基本上就可以看见三个节点进程都能启动。
第二个原因就是防火墙问题,先查看自己的防火墙是否启动,如果启动关闭,如果防火墙没有启动,我们也不能放着不管,重新启动防火墙,然后再关闭基本上就可以了,我的就是重新启动防火墙再关闭才解决这个问题。
我的启动情况
[root@zj01 ~]# zkstatus.sh
============= zj01 status zk ==========
ZooKeeper JMX enabled by default
Using config: /apps/zookeeper/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
============= zj02 status zk ==========
ZooKeeper JMX enabled by default
Using config: /apps/zookeeper/bin/../conf/zoo.cfg
Mode: follower
============= zj03 status zk ==========
ZooKeeper JMX enabled by default
Using config: /apps/zookeeper/bin/../conf/zoo.cfg
Mode: leader
查看防火墙状态
systemctl status firewalld.service
#或者
systemctl firewalld --start
开启防火墙
systemctl start firewalld.service
关闭防火墙
systemctl stop firewalld.service
关闭防火墙开机自启
systemctl disable firewalld.service
修改后的状态如下:
[root@zj01 ~]# zkstatus.sh
============= zj01 status zk ==========
ZooKeeper JMX enabled by default
Using config: /apps/zookeeper/bin/../conf/zoo.cfg
Mode: follower
============= zj02 status zk ==========
ZooKeeper JMX enabled by default
Using config: /apps/zookeeper/bin/../conf/zoo.cfg
Mode: follower
============= zj03 status zk ==========
ZooKeeper JMX enabled by default
Using config: /apps/zookeeper/bin/../conf/zoo.cfg
Mode: leader
我的就是防火墙的问题,希望这个问题对您有帮助,如有什么问题请联系我呦
注意:我的是有时候启动后会报错,我也不清楚具体原因,如果哪位小伙伴能解决Centos的防火墙问题,可以告知我一声,谢谢了