zookeeper服务启动闪退

最近在学习zookeeper,在本机单IP下构建一个伪集群时,配置好后启动第一个zookeeper服务,出现闪退的情况

解决思路:

1、在zkServer.cmd中末尾增加pause,这样就不会闪退了。可以看到输出的日志

setlocal
call "%~dp0zkEnv.cmd"

set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
set ZOOCFG=F:\\zookeeper\\zookeeper-3.4.10\\conf\\zoo.cfg --单机伪集群下,共享在一个文件夹时,可以在这配置映射文件路径,覆盖zkEnv.cmd中的此项配置
echo on
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %
endlocal
pause

2、通过日志查看发现错误如下:

2017-12-07 14:50:22,192 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing F:\\zookeeper\\zookeeper-3.4.10\\conf\\zoo.cfg
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:154)
        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: F:\zookeeper\dataDir\myid file is missing
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:406)
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:150)
        ... 2 more
Invalid config, exiting abnormally
F:\zookeeper\zookeeper-3.4.10\bin>endlocal
F:\zookeeper\zookeeper-3.4.10\bin>pause
请按任意键继续. . .

3、通过日志发现找不到myid文件,而这个myid文件的查找路径是通过zoo.cfg中dataDir这个key配置的,所以找到此配置发现确实填写错误了

4、更改过来之后zkServer.cmd服务重启之后就好了。

PS: 如果不是以上这类的报错,那么查看zoo.cfg这个文件在服务启动后是否能够正确的被寻找到

你可能感兴趣的:(zookeeper,zookeeper,集群)