zookeeper Client Session 0x0 for server null

本文记录了作者在虚拟机外部尝试调用单机模式下ZooKeeper服务时遇到的连接失败问题及解决过程。错误提示为连接超时,并最终定位到虚拟机防火墙导致的问题。关闭防火墙后,连接恢复正常。
昨天自己写程序来测试调用单机模式的zookeeper服务。服务的安装不说了,网上太多了。当我安装完毕,在虚拟机本地调用zkCli来调试,没有问题。但在虚拟机外调用,总是连接不上,报错:

[08-21 18:20:59 WARN ] org.apache.zookeeper.ClientCnxn$SendThread - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException : Connection timed out: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:286)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1041)
[08-21 18:20:59 DEBUG] org.apache.zookeeper.ClientCnxnSocketNIO - Ignoring exception during shutdown input

最后发现时虚拟机防火墙开着,关闭防火墙后则一切正常。
关闭防火墙命令:service iptables stop

25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Client environment:java.library.path=/usr/local/hadoop/lib/native 25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/tmp 25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA> 25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux 25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Client environment:os.arch=amd64 25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Client environment:os.version=3.10.0-1160.el7.x86_64 25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Client environment:user.name=root 25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Client environment:user.home=/root 25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Client environment:user.dir=/usr/local/hadoop/sbin 25/12/02 16:25:39 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=abc:2181,bcd:2181,cde:2181 sessionTimeout=5000 watcher=org.apache.hadoop.ha.ActiveStandbyElector$WatcherWithClientRef@478190fc 25/12/02 16:25:39 INFO zookeeper.ClientCnxn: Opening socket connection to server bcd/192.168.177.131:2181. Will not attempt to authenticate using SASL (unknown error) 25/12/02 16:25:39 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.ConnectException: 拒绝连接 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:715) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081) 25/12/02 16:25:39 INFO zookeeper.ClientCnxn: Opening socket connection to server abc/192.168.177.130:2181. Will not attempt to authenticate using SASL (unknown error) 25/12/02 16:25:39 INFO zookeeper.ClientCnxn: Socket connection established to abc/192.168.177.130:2181, initiating session 25/12/02 16:25:39 INFO zookeeper.ClientCnxn: Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect 25/12/02 16:25:39 INFO zookeeper.ClientCnxn: Opening socket connection to server cde/192.168.177.132:2181. Will not attempt to authenticate using SASL (unknown error) 25/12/02 16:25:39 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.ConnectException: 拒绝连接 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:715) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081) 25/12/02 16:25:41 INFO zookeeper.ClientCnxn: Opening socket connection to server bcd/192.168.177.131:2181. Will not attempt to authenticate using SASL (unknown error) 25/12/02 16:25:41 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.ConnectException: 拒绝连接 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:715) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081) 25/12/02 16:25:42 INFO zookeeper.ClientCnxn: Opening socket connection to server abc/192.168.177.130:2181. Will not attempt to authenticate using SASL (unknown error) 25/12/02 16:25:42 INFO zookeeper.ClientCnxn: Socket connection established to abc/192.168.177.130:2181, initiating session 25/12/02 16:25:42 INFO zookeeper.ClientCnxn: Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect 25/12/02 16:25:43 INFO zookeeper.ClientCnxn: Opening socket connection to server cde/192.168.177.132:2181. Will not attempt to authenticate using SASL (unknown error) 25/12/02 16:25:43 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.ConnectException: 拒绝连接 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:715) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081) 25/12/02 16:25:44 ERROR ha.ActiveStandbyElector: Connection timed out: couldn't connect to ZooKeeper in 5000 milliseconds 25/12/02 16:25:44 INFO zookeeper.ClientCnxn: Opening socket connection to server bcd/192.168.177.131:2181. Will not attempt to authenticate using SASL (unknown error) 25/12/02 16:25:44 INFO zookeeper.ZooKeeper: Session: 0x0 closed 25/12/02 16:25:44 FATAL ha.ZKFailoverController: Unable to start failover controller. Unable to connect to ZooKeeper quorum at abc:2181,bcd:2181,cde:2181. Please check the configured value for ha.zookeeper.quorum and ensure that ZooKeeper is running. 25/12/02 16:25:44 INFO zookeeper.ClientCnxn: EventThread shut down
最新发布
12-04
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值