zookeeper启动闪退
双击zkServer.cmd启动 时候 cmd窗口一闪而过 闪退
这我有在 zookeeper的 bin目录下,手动 cmd 启动zookeeper,为了看清 日志的报错信息
报错日志


x:\x\zookeeper\tomcat\zookeeper-3.4.9\bin>zkServer.cmd

Dx\x\zookeeper\tomcat\zookeeper-3.4.9\bin>call "x:\x\JDK\jdk"\bin\java "-D
zookeeper.log.dir=x:\x\zookeeper\tomcat\zookeeper-3.4.9\bin\.." "-Dzookeeper.
root.logger=INFO,CONSOLE" -cp "x:\x\zookeeper\tomcat\zookeeper-3.4.9\bin\..\b
uild\classes;x:\work\zookeeper\tomcat\zookeeper-3.4.9\bin\..\build\lib\*;x:\x
\zookeeper\tomcat\zookeeper-3.4.9\bin\..\*;x:\x\zookeeper\tomcat\zookeeper-3.
4.9\bin\..\lib\*;x:\x\zookeeper\tomcat\zookeeper-3.4.9\bin\..\conf" org.apach
e.zookeeper.server.quorum.QuorumPeerMain "x:\x\zookeeper\tomcat\zookeeper-3.4
.9\bin\..\conf\zoo.cfg"
2019-10-31 18:24:21,427 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading co
nfiguration from: D:\work\zookeeper\tomcat\zookeeper-3.4.9\bin\..\conf\zoo.cfg
2019-10-31 18:24:21,427 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopu
rge.snapRetainCount set to 3
2019-10-31 18:24:21,427 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopu
rge.purgeInterval set to 0
2019-10-31 18:24:21,427 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge
 task is not scheduled.
2019-10-31 18:24:21,427 [myid:] - WARN  [main:QuorumPeerMain@113] - Either no co
nfig or no quorum defined in config, running  in standalone mode
2019-10-31 18:24:21,474 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading co
nfiguration from: D:\work\zookeeper\tomcat\zookeeper-3.4.9\bin\..\conf\zoo.cfg
2019-10-31 18:24:21,474 [myid:] - INFO  [main:ZooKeeperServerMain@96] - Starting
 server
2019-10-31 18:24:21,490 [myid:] - INFO  [main:Environment@100] - Server environm
ent:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT
2019-10-31 18:24:21,490 [myid:] - INFO  [main:Environment@100] - Server environm
ent:host.name=10.168.103.24
2019-10-31 18:24:21,490 [myid:] - INFO  [main:Environment@100] - Server environm
ent:java.version=1.8.0_144
2019-10-31 18:24:21,490 [myid:] - INFO  [main:Environment@100] - Server environm
ent:java.vendor=Oracle Corporation
2019-10-31 18:24:21,490 [myid:] - INFO  [main:Environment@100] - Server environm
ent:java.home=D:\work\JDK\jdk\jre
2019-10-31 18:24:21,490 [myid:] - INFO  [main:Environment@100] - Server environm
ent:java.class.path=x:\x\zookeeper\tomcat\zookeeper-3.4.9\bin\..\build\classe
s;x:\x\zookeeper\tomcat\zookeeper-3.4.9\bin\..\build\lib\*;D:\work\zookeeper\
tomcat\zookeeper-3.4.9\bin\..\zookeeper-3.4.9.jar;D:\work\zookeeper\tomcat\zooke
eper-3.4.9\bin\..\lib\jline-0.9.94.jar;x:\x\zookeeper\tomcat\zookeeper-3.4.9\
bin\..\lib\log4j-1.2.16.jar;x:\x\zookeeper\tomcat\zookeeper-3.4.9\bin\..\lib\
netty-3.10.5.Final.jar;x:\x\zookeeper\tomcat\zookeeper-3.4.9\bin\..\lib\slf4j
-api-1.6.1.jar;D:\work\zookeeper\tomcat\zookeeper-3.4.9\bin\..\lib\slf4j-log4j12
-1.6.1.jar;D:\work\zookeeper\tomcat\zookeeper-3.4.9\bin\..\conf
2019-10-31 18:24:21,490 [myid:] - INFO  [main:Environment@100] - Server environm
ent:java.library.path=D:\work\JDK\jdk\bin;C:\Windows\Sun\Java\bin;C:\Windows\sys
tem32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Wind
ows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\D:\work\
JDK\jdk\bin;D:\work\Git\Git\cmd;C:\Program Files\MySQL\MySQL Server 5.7\bin;D:\w
ork\Svn\bin;.
2019-10-31 18:24:21,505 [myid:] - INFO  [main:Environment@100] - Server environm
ent:java.io.tmpdir=C:\Users\admin\AppData\Local\Temp\
2019-10-31 18:24:21,505 [myid:] - INFO  [main:Environment@100] - Server environm
ent:java.compiler=<NA>
2019-10-31 18:24:21,505 [myid:] - INFO  [main:Environment@100] - Server environm
ent:os.name=Windows 7
2019-10-31 18:24:21,505 [myid:] - INFO  [main:Environment@100] - Server environm
ent:os.arch=amd64
2019-10-31 18:24:21,505 [myid:] - INFO  [main:Environment@100] - Server environm
ent:os.version=6.1
2019-10-31 18:24:21,505 [myid:] - INFO  [main:Environment@100] - Server environm
ent:user.name=admin
2019-10-31 18:24:21,505 [myid:] - INFO  [main:Environment@100] - Server environm
ent:user.home=C:\Users\admin
2019-10-31 18:24:21,505 [myid:] - INFO  [main:Environment@100] - Server environm
ent:user.dir=D:\work\zookeeper\tomcat\zookeeper-3.4.9\bin
2019-10-31 18:24:21,505 [myid:] - ERROR [main:ZooKeeperServerMain@64] - Unexpect
ed exception, exiting abnormally
java.io.IOException: Unable to create data directory D:workzookeeper    omcatzoo
keeper-3.4.9log\version-2
        at org.apache.zookeeper.server.persistence.FileTxnSnapLog.<init>(FileTxn
SnapLog.java:85)
        at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeep
erServerMain.java:110)
        at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooK
eeperServerMain.java:87)
        at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerM
ain.java:53)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(Qu
orumPeerMain.java:116)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain
.java:78)

x:\x\zookeeper\tomcat\zookeeper-3.4.9\bin>endlocal

解决:

首先我先看到了 这句
就是 报错原因呗
ERROR [main:ZooKeeperServerMain@64] - Unexpect
ed exception, exiting abnormally
我各种 百度 和改配置文件 还是依然闪退各种 不好试

我有仔细看了一下报错日志 有发下了下面这句
java.io.IOException: Unable to create data directory D:workzookeeper omcatzoo
keeper-3.4.9log\version-2
这个什么意思: 无法创建目录 我恍然大悟 应为在zookeeper的conf里的有zoo.cfg的配置文件
在这里插入图片描述
就是这路径有问题
解决就是的dataDir目录使用双反斜杠“\”,就行了

dataDir=x:\\x\\x\\tomcat\\zookeeper-3.4.9\\data

各种错误信息都不一样 有可能是你的端口被占用了杀一下进程,
也可以找到zoo.conf中配置的dataDir和dataLogDir路径。然后删除两个文件夹下的version -2文件夹, 实在不行在解压一份从新配置一下
我的改完重启是成功
在这里插入图片描述

Logo

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

更多推荐