解决Zookeeper集群启动报错Caused by: java.lang.IllegalArgumentException: ...myid file is missing,有myid却还报错问题

出现问题

今天在采用单机伪分布式的方式搭建了Zookeeper集群后,启动时发现控制台报启动成功,但是查看zookeeper进程时却发现并没有正在运行的zookeeper进程
解决Zookeeper集群启动报错Caused by: java.lang.IllegalArgumentException: ...myid file is missing,有myid却还报错问题_第1张图片
于是,采用前台启动的方式(./zkServer.sh start-foreground)再次启动,发现启动报错
解决Zookeeper集群启动报错Caused by: java.lang.IllegalArgumentException: ...myid file is missing,有myid却还报错问题_第2张图片

ZooKeeper JMX enabled by default
Using config: /opt/myzookeeper/zk01/bin/../conf/zoo.cfg
2019-10-29 08:48:47,851 [myid:] - INFO  [main:QuorumPeerConfig@136] - Reading configuration from: /opt/myzookeeper/zk01/bin/../conf/zoo.cfg
2019-10-29 08:48:47,865 [myid:] - INFO  [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 127.0.0.1 to address: /127.0.0.1
2019-10-29 08:48:47,865 [myid:] - INFO  [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 127.0.0.1 to address: /127.0.0.1
2019-10-29 08:48:47,866 [myid:] - INFO  [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 127.0.0.1 to address: /127.0.0.1
2019-10-29 08:48:47,866 [myid:] - INFO  [main:QuorumPeerConfig@398] - Defaulting to majority quorums
2019-10-29 08:48:47,868 [myid:] - ERROR [main:QuorumPeerMain@88] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /opt/myzookeeper/zk01/bin/../conf/zoo.cfg
	at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:156)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:104)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:81)
Caused by: java.lang.IllegalArgumentException: /myzookeeper/zk01/mydata/myid file is missing
	at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:408)
	at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:152)
	... 2 more

从Caused by来看,上面说我的zk01/mydata/myid文件不存在,file is missing。于是我就进入到相应目录查看我的myid文件,发现分明有啊!且其中的内容也是1,没有空格等其他的多余字符。为何扔报错?
在这里插入图片描述

问题解决:

仔细查看报错信息会发现提示错误审查:/opt/myzookeeper/zk01/bin/…/conf/zoo.cfg
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /opt/myzookeeper/zk01/bin/…/conf/zoo.cfg
据此推测应该是自己的配置文件zoo.cfg修改有误,于是来到zoo.cfg进行检查
解决Zookeeper集群启动报错Caused by: java.lang.IllegalArgumentException: ...myid file is missing,有myid却还报错问题_第3张图片
果然,由于我配置的三台zookeeper,zk01、zk02、zk03均在/opt/myzookeeper下,因此当配置自己的数据和log路径时应将路径写全
解决Zookeeper集群启动报错Caused by: java.lang.IllegalArgumentException: ...myid file is missing,有myid却还报错问题_第4张图片
补全zoo.cfg中的数据和log路径后再次逐个启动集群发现问题解决,集群全部启动成功
在这里插入图片描述
解决Zookeeper集群启动报错Caused by: java.lang.IllegalArgumentException: ...myid file is missing,有myid却还报错问题_第5张图片

总结:

出现myid file is missing的报错时,可能跟你conf下的zoo.cfg中dataDir与dataLogDir的路径配置不正确的问题,在写这两行配置时一定要查看你的zookeeper集群目录,将路径补全。
在这里插入图片描述
解决Zookeeper集群启动报错Caused by: java.lang.IllegalArgumentException: ...myid file is missing,有myid却还报错问题_第6张图片

你可能感兴趣的:(坑&bug,zookeeper集群搭建问题)