运行zookeeperd后显示启动成功:


JMX enabled by default
Using config: /data/programfiles/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED


但用zkServer.sh status查看,反馈如下:


JMX enabled by default
Using config: /data/programfiles/zookeeper-3.4.5/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.


很奇怪,我用netstat -lntup查了一下端口,没发现2018端口被启用


查了zookeeper.out日志,发现如下的错误:


2014-04-16 11:59:54,425 [myid:] - ERROR [main:ZooKeeperServerMain@63] - Unexpected exception, exiting abnormally
java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:344)
    at sun.nio.ch.Net.bind(Net.java:336)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
    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:95)
    at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:110)
    at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:86)
    at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:52)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)

从错误信息来看,是端口被使用了,但我用netstat -lntup是没被使用的,再用 lsof -i:2181,发现了2181端口果然被占用了


[root@ programfiles]# lsof -i:2181
COMMAND     PID USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
memcached 15843 root   56u  IPv4 1650939492      0t0  TCP .:11213->.:eforward (ESTABLISHED)
php-cgi   28154  www    7u  IPv4 1650939491      0t0  TCP .:eforward->.:11213 (ESTABLISHED)


接下来就很好办了,启用另外一个端口就ok了

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐