当前位置: 代码迷 >> 综合 >> zookeepr 遇坑解决Cannot open channel to X at election address Connection refused
  详细解决方案

zookeepr 遇坑解决Cannot open channel to X at election address Connection refused

热度:85   发布时间:2023-09-20 09:28:03.0

搭建zookeeper集群的时候3个节点,配置明明正确,却总是由一个启动不了,找了半天原因也没有找到。

错误信息如下


    2017-11-26 10:35:56,341 [myid:3] - INFO  [WorkerReceiver[myid=3]:FastLeaderElection@602] - Notification: 1 (message format version), 1 (n.leader), 0x100000000 (n.zxid), 0x1 (n.round), LEADING (n.state), 1 (n.sid), 0x4 (n.peerEpoch) LOOKING (my state)
    2017-11-26 10:35:56,343 [myid:3] - INFO  [WorkerSender[myid=3]:QuorumPeer$QuorumServer@184] - Resolved hostname: hadoop-senior02.ibeifeng.com to address: hadoop-senior02.ibeifeng.com/192.168.129.129
    2017-11-26 10:35:56,344 [myid:3] - INFO  [WorkerReceiver[myid=3]:FastLeaderElection@602] - Notification: 1 (message format version), 3 (n.leader), 0x100000000 (n.zxid), 0x1 (n.round), LOOKING (n.state), 3 (n.sid), 0x3 (n.peerEpoch) LOOKING (my state)
    2017-11-26 10:35:57,642 [myid:3] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /127.0.0.1:56090
    2017-11-26 10:35:57,646 [myid:3] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ServerCnxn@324] - The list of known four letter word commands is : [{2003003491=wchc, 1668247155=cons, 1668445044=crst, 1735683435=gtmk, 1936881266=srvr, 1835955314=mntr, 2003003504=wchp
    , 1668247142=conf, 1937010027=stmk, 2003003507=wchs, 1769173615=isro, 1936880500=srst, 1920298859=ruok, 1937006964=stat, 1701738089=envi, 1685417328=dump}]
    2017-11-26 10:35:57,646 [myid:3] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ServerCnxn@325] - The list of enabled four letter word commands is : [[wchs, srst, dump, gtmk, crst, envi, stmk, mntr, isro, conf, ruok, stat, srvr, cons]]
    2017-11-26 10:35:57,646 [myid:3] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@892] - Processing srvr command from /127.0.0.1:56090
    2017-11-26 10:35:57,647 [myid:3] - INFO  [Thread-1:NIOServerCnxn@1040] - Closed socket connection for client /127.0.0.1:56090 (no session established for client)
    2017-11-26 10:35:59,405 [myid:3] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /127.0.0.1:56091
    2017-11-26 10:35:59,416 [myid:3] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@892] - Processing srvr command from /127.0.0.1:56091
    2017-11-26 10:35:59,417 [myid:3] - INFO  [Thread-2:NIOServerCnxn@1040] - Closed socket connection for client /127.0.0.1:56091 (no session established for client)
    2017-11-26 10:35:59,545 [myid:3] - INFO  [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@854] - Notification time out: 6400
    2017-11-26 10:35:59,547 [myid:3] - WARN  [WorkerSender[myid=3]:QuorumCnxManager@584] - Cannot open channel to 2 at election address hadoop-senior02.ibeifeng.com/192.168.129.129:3888
    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: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:745)

 


最后参照stackoverflow 解决方法如下

server1 配置如下


    server.1=0.0.0.0:2888:3888
    server.2=hadoop-senior02.ibeifeng.com:2888:3888
    server.3=hadoop-senior03.ibeifeng.com:2888:3888


server2 配置如下

    server.1=hadoop-senior.ibeifeng.com:2888:3888
    server.2=0.0.0.0:2888:3888
    server.3=hadoop-senior03.ibeifeng.com:2888:3888


server3 配置如下

    server.1=hadoop-senior.ibeifeng.com:2888:3888
    server.2=hadoop-senior03.ibeifeng.com:2888:3888
    server.3=0.0.0.0:2888:3888


解决问题stackoverflow 地址 http://stackoverflow.com/questions/30940981/zookeeper-error-cannot-open-channel-to-x-at-election-address#

网上寻求解决方案

1.http://freeman983.iteye.com/blog/2053037   log目录没有创建导致出错 并不是原因。

2.http://blog.csdn.net/qianggezhishen/article/details/49363349  (我的配置都是对的 但是仍然报错)

ZooKeeper安装使用时遇到各种奇怪问题的解决方法:

1.nohup:failed to run command ‘Java’: No such file or directory
2.Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

a.检查myid文件数字是否跟配置的能对的上

b.检查myid文件是否已经拷贝到dataDIr配置的路径里了

c.检查/etc/profile和/etc/environment 是否设置了Java和Zookeeper的路径

d.Zookeeper集群节点必须是3个以上

如果遇到 java.net.NoRouteToHostException: No route to host

建议关闭防火墙试试

Java.net.NoRouteToHostException:No route to host

上网查询的结论如下:

没有路由连接到本机,无法到达远程主机,

原因:防火墙干扰或中间路由器停机

(用telnet查看该机器是否正常连接,结果如下:

Trying 199.155.122.91...
telnet: connect to address 199.155.122.91: No route to host
telnet: Unable to connect to remote host: No route to host)

解决的办法是:和防火墙规则有关,关闭防火墙就可以了

关闭防火墙之后,结果如下:

Trying 199.155.122.91...
telnet: connect to address 199.155.122.91: Connection refused
telnet: Unable to connect to remote host: Connection refused

 

  相关解决方案