平台:centos-6.3-i386
jdk-7u51
storm 0.9.1
python 2.6.6
hadoop 1.2.1
运行zookeeperd后显示启动成功:
JMX enabled by default
Using config: /data/programfiles/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
但用bin/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查了一下端口,没发现2181端口被启用
查了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了