linux下,zookeeper安装并启动起来了,
将log4j.properties放在工程的classpath下,然后启动工程,发现控制台报错:
2017-03-02 19:52:32,270 INFO [org.apache.zookeeper.ZooKeeper] - Initiating client connection, connectString=192.168.153.128:2181 sessionTimeout=30000 watcher=org.I0Itec.zkclient.ZkClient@1d6ba2b
2017-03-02 19:52:32,288 INFO [org.apache.zookeeper.ClientCnxn] - Opening socket connection to server 192.168.153.128/192.168.153.128:2181. Will not attempt to authenticate using SASL (unknown error)
2017-03-02 19:52:53,291 WARN [org.apache.zookeeper.ClientCnxn] - 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(SocketChannelImpl.java:739)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
2017-03-02 19:52:54,394 INFO [org.apache.zookeeper.ClientCnxn] - Opening socket connection to server 192.168.153.128/192.168.153.128:2181. Will not attempt to authenticate using SASL (unknown error)
经检查,是linux下防火墙未关闭,使用一下命令关闭防火墙:
service iptables stop
查看防火墙状态:
service iptables status
参考资料:https://www.cnblogs.com/hfultrastrong/p/7876198.html