【大数据】启动zookeeper报错:ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally

启动zookeeper报错:ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally

场景:
1.给三台机器安装zookeeper集群报错:ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
2.环境描述
系统:                CentOS 7.6
zookeeper版本:       3.4.6
安装目录:            /opt/zookeeper-3.4.6
安装的用户:          hadoop
zookeeper data目录:  /opt/zookeeper-3.4.6/zookeepertmp        --需要手动创建
zookeeper tmp目录:   /opt/zookeeper-3.4.6/zookeepertmp/log    --需要手动创建
三台机器主机名:      note01、note02、note03

解决:
报错信息如下:
$ vi zookeeper.out

2019-03-31 22:48:53,422 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
2019-03-31 22:48:53,447 [myid:] - INFO  [main:QuorumPeerConfig@340] - Defaulting to majority quorums
2019-03-31 22:48:53,449 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:123)
        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: /opt/zookeeper-3.4.6/zookeepertmp/myid file is missing
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:350)
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:119)
        ... 2 more
Invalid config, exiting abnormally

1.网上反馈很多的是因为没有创建myid文件以及配置文件配错(尴尬,毕竟是新手);
2.从myid文件先入手,这个第一次启动的时候确实没有创建myid文件,分别在三台机器创建myid文件并写入机器id号
在note01创建myid
$ cd /opt/zookeeper-3.4.6/zookeepertmp
$ echo "1" > myid

在note02创建myid
$ cd /opt/zookeeper-3.4.6/zookeepertmp
$ echo "2" > myid

在note03创建myid
$ cd /opt/zookeeper-3.4.6/zookeepertmp
$ echo "3" > myid

3.把zookeeper data目录下除了log文件夹和myid外其他的文件和文件夹删除
$ rm zookeeper_server.pid -rf
$ rm zookeeper.out -rf
$ rm version-2 -rf

4.再检查zoo.cfg文件是否配置正确
最后发现最后的
server.1=note2:2888:3888
server.2=note3:2888:3888
server.3=note4:2888:3888
前面的主机名错误,正确的应该是
server.1=note02:2888:3888
server.2=note03:2888:3888
server.3=note04:2888:3888

5.再次尝试启动zookeeper
分别在三台机器执行启动命令
$ zkServer.sh start

分别在三台机器执行查看状态命令
$ zkServer.sh status

6.居然还报错,不应该啊!!!死马当活马医,重启一下机器
$ exit
# reboot


7.再次尝试启动zookeeper
分别在三台机器执行启动命令
$ zkServer.sh start

分别在三台机器执行查看状态命令
[hadoop@note03 zookeepertmp]$ zkServer.sh status
JMX enabled by default
Using config: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: leader

[hadoop@note04 zookeepertmp]$ zkServer.sh status
JMX enabled by default
Using config: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follower

[hadoop@note02 zookeepertmp]$ zkServer.sh status
JMX enabled by default
Using config: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follower

看到这里证明zookeeper启动正常,搞定!!!

 

你可能感兴趣的:(大数据报错)