【已解决】zookeeper启动失败Error contacting service. It is probably not running并且jps没有QuorumPeerMain进程

[root@node02 conf]# /export/servers/zookeeper-3.4.9/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@node02 conf]# /export/servers/zookeeper-3.4.9/bin/zkServer.sh  status
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper-3.4.9/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
[root@node02 conf]# jps
10913 Jps

问题:

启动zookpeerer,查看状态显示:Error contacting service. It is probably not running.,查看jps也没有QuorumPeerMain进程。

解决过程:

step1:查因

查看zookeeper.out文件来寻找问题原因:(当前处于哪个目录,执行完zkServer.sh start命令, zookeeper.out就会写在哪个目录)

[root@node02 conf]# ll
total 20
-rw-r--r-- 1 root root  535 Jul 22 17:34 configuration.xsl
-rw-r--r-- 1 root root 2161 Jul 22 17:34 log4j.properties
-rw-r--r-- 1 root root 1225 Jul 22 18:01 zoo.cfg
-rw-r--r-- 1 root root 1387 Jul 22 19:19 zookeeper.out
-rw-r--r-- 1 root root  922 Jul 22 17:34 zoo_sample.cfg
You have new mail in /var/spool/mail/root
[root@node02 conf]# vim zookeeper.out 
2022-07-22 19:19:48,894 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading configuration from: /export/servers/zookeeper-3.4.9/bin/../conf/zoo.cfg
2022-07-22 19:19:48,922 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: node03 to address: node03/192.168.202.120
2022-07-22 19:19:48,923 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /export/servers/zookeeper-3.4.9/bin/../conf/zoo.cfg
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:144)
        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.NumberFormatException: For input string: "1 #表示å¤<9a>é<95>¿æ<97>¶é<97>´ï¼<88>å°<8f>æ<97>¶ï¼<89>å<90><88>并ä¸<80>ä¸<8b>å¿«ç<85>§ç<89><88>æ<9c>¬"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:580)
        at java.lang.Integer.parseInt(Integer.java:615)
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:199)
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:140)
        ... 2 more
Invalid config, exiting abnormally

重点看Caused by的第一行(如果你的原因和我不一样,就去找对应的原因即可,应该网上都有)
这里乱码了,我看到"1 #猜测是不是某个地方的注释的原因,果真是,我的配置文件中有两个地方我将注释和命令写在了了同一行,错误示范如下:

[root@node02 conf]# vim zoo.cfg 
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/export/servers/zookeeper-3.4.9/zkdatas
dataLogDir=/export/servers/zookeeper-3.4.9/logs

# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
autopurge.snapRetainCount=3 #表示snapshots快照版本保存几份
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=1 #表示多长时间(小时)合并一下快照版本

#给每台机器都分配了唯一的id值,1、2、3
server.1=node01:2888:3888
server.2=node02:2888:3888
server.3=node03:2888:3888

step2:解决

于是我将下面两行的注释单独放在一行
autopurge.snapRetainCount=3 #表示snapshots快照版本保存几份
autopurge.purgeInterval=1 #表示多长时间(小时)合并一下快照版本
修改以后的配置文件:

[root@node02 conf]# vim zoo.cfg 
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/export/servers/zookeeper-3.4.9/zkdatas
dataLogDir=/export/servers/zookeeper-3.4.9/logs

# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
autopurge.snapRetainCount=3
#表示snapshots快照版本保存几份

# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=1 
#表示多长时间(小时)合并一下快照版本

#给每台机器都分配了唯一的id值,1、2、3
server.1=node01:2888:3888
server.2=node02:2888:3888
server.3=node03:2888:3888

然后再次尝试开启zookeeper服务就成功了

[root@node02 conf]# cd ..
[root@node02 zookeeper-3.4.9]# /export/servers/zookeeper-3.4.9/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@node02 zookeeper-3.4.9]# /export/servers/zookeeper-3.4.9/bin/zkServer.sh  status
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: leader
[root@node02 zookeeper-3.4.9]# jps
11154 QuorumPeerMain
11221 Jps

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值