Missing election port for server: 2
【整理日期】2023年6月1日
【基础环境】JDK 1.8.0_372
、Zookeeper 3.4.5
【问题描述】进行部署分布式,配置了myid
、zoo.cfg
等文件之后,执行 bin/zkServer.sh start
启动 Zookeeper服务,发现无法启动Zookeeper服务
# 一般习惯用restart来启动一个服务, 如果当前服务已经是运行状态,直接start可能会失败
[root@node01 zookeeper-3.4.5]# bin/zkServer.sh restart
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.5/bin/../conf/zoo.cfg
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.5/bin/../conf/zoo.cfg
# 这一段说没有运行着的zookeeper
Stopping zookeeper ... no zookeeper to stop (could not find file /opt/module/zookeeper-3.4.5/zkData/zookeeper_server.pid)
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@node01 zookeeper-3.4.5]#
[root@node01 zookeeper-3.4.5]#
# 然后检查zookeeper服务的状态
[root@node01 zookeeper-3.4.5]# bin/zkServer.sh status
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.5/bin/../conf/zoo.cfg
# 发现服务是未运行状态
Error contacting service. It is probably not running.
[root@node01 zookeeper-3.4.5]#
【报错详情】检查了 /opt/module/zookeeper-3.4.5/zookeeper.out
文件,发现如下报错
2023-06-01 13:43:38,488 [myid:] - INFO [main:QuorumPeerConfig@101] - Reading configuration from: /opt/module/zookeeper-3.4.5/bin/../conf/zoo.cfg
2023-06-01 13:43:38,508 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /opt/module/zookeeper-3.4.5/bin/../conf/zoo.cfg
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:121)
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: Missing election port for server: 2
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:305)
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:117)
... 2 more
Invalid config, exiting abnormally
【问题处理】
网上百度了一下,发现是 /opt/module/zookeeper-3.4.5/conf/zoo.cfg
配置错了,配置文件中写的是:
# =================cluster=================
server.1=node01:2888:3888
server.2=node02.2888:3888
server.3=node03:2888:3888
正确的应该是这样
# =================cluster=================
server.1=node01:2888:3888
server.2=node02:2888:3888
server.3=node03:2888:3888
修改之后,执行 bin/zkServer.sh restart
启动zookeeper后,查看服务状态
# node01
[root@node01 bin]# ./zkServer.sh status
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower
[root@node01 bin]#
# node02
[root@node02 bin]# ./zkServer.sh status
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower
[root@node02 bin]#
# node03
[root@node03 bin]# ./zkServer.sh status
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: leader
[root@node03 bin]#
EOF
标签:bin,opt,zookeeper,启动,Zookeeper,module,3.4,失败,root From: https://www.cnblogs.com/harleyblogs/p/17448743.html