zookeeper启动成功,但是使用bin/zkServer.sh 电脑 status命令显示没有真正运行成功
[root@oraserver apache-zookeeper-3.5.7-bin]# bin/zkServer.sh start/usr/bin/javaZooKeeper JMX enabled by defaultUsing config: /root/data/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfgStarting zookeeper ... FAILED TO START
[root@localhost apache-zookeeper-3.5.7-bin]# bin/zkServer.sh status/usr/bin/javaZooKeeper JMX enabled by defaultUsing config: /root/data/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfgClient port found: 2181. Client address: localhost.Error contacting service. It is probably not 电脑 running.
查看日志如下
[root@oraserver apache-zookeeper-3.5.7-bin]# cd logs[root@oraserver logs]# lszookeeper-root-server-oraserver.out[root@oraserver logs]# cat zookeeper-root-server-oraserver.out
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: 电脑 Error processing /home/crxj-coll/zookeeper-3.4.5/bin/../conf/zoo.cfg at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:121) 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: myid file is missing at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:344) at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:117) ... 2 moreInvalid config, exiting abnormally
根据日志我们可以看出myid文件缺失,应该是myid文件的路径不对,修改zoo.cfg配置文件中的dataDir属性,保证路径正确即可,我这里是在zookeeper安装目录中新建了一个data目录存放myid文件,dataDir修改为如下所示。
# The number of 电脑 milliseconds of each ticktickTime=2000# The number of ticks that the initial# synchronization phase can takeinitLimit=10# The number of ticks that can pass between# sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just# example sakes.dataDir=/root/data/apache-zookeeper-3.5.7-bin/data# the port at which the clients will connectclientPort=2181server.0=192.168.157.129:2888:3888server.1=192.168.157.130:2888:3888server.2=192.168.157.131:2888:3888
修改完成后便可成功启动。
[root@oraserver apache-zookeeper-3.5.7-bin]# bin/zkServer.sh start/usr/bin/javaZooKeeper JMX enabled by defaultUsing config: /root/data/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfgStarting zookeeper ... STARTED[root@oraserver apache-zookeeper-3.5.7-bin]# 电脑 bin/zkServer.sh status/usr/bin/javaZooKeeper JMX enabled by defaultUsing config: /root/data/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfgClient port found: 2181. Client address: localhost.Mode: follower
电脑