zookeeper无法启动解决

今日为了释放空间,kill了zookeeper进程,没想到kill了后就启动不起来了

成都创新互联公司咨询电话:18982081108,为您提供成都网站建设网页设计及定制高端网站建设服务,成都创新互联公司网页制作领域10年,包括宣传片制作等多个行业拥有丰富的网站营销经验,选择成都创新互联公司,为网站锦上添花!

提示已正常启动

[root@lnx-a-11 bin]# ./zkServer.sh start
JMX enabled by default
Using config: /home/tester/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@lnx-air-9-27 bin]# ps aux |grep zook

但看后台进程没有

查看zookeeper.out日志,有如下提示:

2015-12-31 17:32:04,090 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /home/tester/zookeeper/bin/../conf/zoo.cfg
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:123)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:101)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
Caused by: java.lang.IllegalArgumentException: /tmp/zookeeper/data/myid file is missing
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:350)
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:119)

提示很明显/tmp/zookeeper/data/myid file is missing

到该目录下发现确实没有myid这个文件,大家知道/tmp文件夹是一个临时目录,里面的文件很可能过一段时间就会被删除

查看/etc/cron.daily/tmpwatch文件,显示如下内容

#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
    -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
    -X '/tmp/hsperfdata_*' 10d /tmp
/usr/sbin/tmpwatch "$flags" 30d /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
    if [ -d "$d" ]; then
    /usr/sbin/tmpwatch "$flags" -f 30d "$d"
    fi
done

可以知道/tmp文件中的内容除了设定的文件将会10d清除一次

所以我们不应该把myid放在/tmp下或者要把这个文件从清除文件中排除出去

添加myid文件,修改zoo.cfg中的data目录后,再次启动,启动成功

[root@lnx-a-11 bin]# ps aux |grep zook
root     21869 24.7  0.8 2584892 35100 pts/2   Sl   17:54   0:01 java -Dzookeeper.log.dir=/home/tester/zookeeper/bin/../logs -Dzookeeper.root.logger=INFO,CONSOLE -cp /home/tester/zookeeper/bin/../build/classes:/home/tester/zookeeper/bin/../build/lib/*.jar:/home/tester/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/tester/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/home/tester/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/home/tester/zookeeper/bin/../lib/log4j-1.2.16.jar:/home/tester/zookeeper/bin/../lib/jline-0.9.94.jar:/home/tester/zookeeper/bin/../zookeeper-3.4.6.jar:/home/tester/zookeeper/bin/../src/java/lib/*.jar:/home/tester/zookeeper/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /home/tester/zookeeper/bin/../conf/zoo.cfg
root     21948  0.0  0.0 103252   808 pts/2    D+   17:55   0:00 grep zook


本文标题:zookeeper无法启动解决
URL标题:http://pwwzsj.com/article/pssscd.html