在启动zookeeper集群时发现没启动成功,查看日志(若未配置日志存放目录则在启动命令目录下打开zookeeper.out文件)发现如下报错:

2019-08-31 09:18:14,407 [myid:] - ERROR [main:QuorumPeerMain@88] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /usr/SFT/zookeeper-3.4.12/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: /usr/SFT/zookeeper-3.4.12/zkData/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
Invalid config, exiting abnormally

提示缺少myid。
打开ZOOKEEPER_HOME/$dataDir目录发现缺少myid文件,之前一不小心把 $dataDir目录删了。。。
在此目录下创建文件并输入id:

echo 1 > myid

注意
1、输入的内容num要与配置文件的server.A中的A字段相匹配,每个节点的myid要唯一。
2、echo 1 >myid中的1>有一个空格,若没有空格,这行代码的结果就不一样了。
3、zk集群安装详见zookeeper安装配置笔记

Logo

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

更多推荐