昨天自己写程序来测试调用单机模式的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

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐