在使用“zkServer.sh start”启动后,显示正常,但是输入zkServer.sh status则Error contacting service. It is probably not running.如下所示
hadoop@master:/usr/local/zookeeper/bin$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 30361.
hadoop@master:/usr/local/zookeeper/bin$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Error contacting service. It is probably not running.
输入zkServer.sh start-foreground查找原因,报如下错误
java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
at org.apache.zookeeper.server.NIOServerCnxnFactory.configure(NIOServerCnxnFactory.java:676)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:167)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:136)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:90)
解决:
(1)查找myid文件是否正确
(2)查看防火墙是否关闭,若没有关闭,则关闭。
我的myid文件配置正确,查看防火墙发现防火墙没有关闭,关闭后问题解决。如下为关闭防火墙操作。
hadoop@master:/usr/local/zookeeper/bin$ sudo ufw status
[sudo] password for hadoop:
Status: inactive
hadoop@master:/usr/local/zookeeper/bin$ sudo ufw disable
Firewall stopped and disabled on system startup