问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

为什么我的zookeeper不能运行?

发布网友 发布时间:2022-04-24 23:28

我来回答

2个回答

懂视网 时间:2022-04-11 10:35

最近我们的集群状态异常,发现启动zk的时候一直失败,看了日志是真的心酸,5s挂机,这要是在开黑,分分钟被举报了,一开始真的没想懂启动zk为什么这么难,而且很稳定的在5s左右失败,通过时间可以判断这个进程还没有完全启动,在这个时间段内,顶多就是在init状态

[root@ZYC3-AQGK-LJCL-SRV05 deployer]# systemctl status zookeeper
● zookeeper.service - ZooKeeper Service
 Loaded: loaded (/etc/systemd/system/zookeeper.service; enabled; vendor preset: disabled)
 Active: active (running) since Mon 2020-03-23 11:29:21 CST; 4s ago
 Docs: http://zookeeper.apache.org
 Process: 31011 ExecStop=/opt/zookeeper/zookeeper-prod/bin/zkServer.sh stop /opt/zookeeper/zookeeper-prod/conf/zoo.cfg (code=exited, status=0/SUCCESS)
 Process: 31129 ExecStart=/opt/zookeeper/zookeeper-prod/bin/zkServer.sh start /opt/zookeeper/zookeeper-prod/conf/zoo.cfg (code=exited, status=0/SUCCESS)
 Main PID: 31138 (java)
 CGroup: /system.slice/zookeeper.service
  └─31138 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /opt/zookeeper/zookeeper-prod/bin/../build/classes:/opt/zookeeper/zookeeper-prod/bin/../build/lib/*.jar:/opt/zookeeper/zoo...

Mar 23 11:29:20 ZYC3-AQGK-LJCL-SRV05 systemd[1]: Starting ZooKeeper Service...
Mar 23 11:29:20 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31129]: ZooKeeper JMX enabled by default
Mar 23 11:29:20 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31129]: Using config: /opt/zookeeper/zookeeper-prod/conf/zoo.cfg
Mar 23 11:29:21 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31129]: Starting zookeeper ... STARTED
Mar 23 11:29:21 ZYC3-AQGK-LJCL-SRV05 systemd[1]: Started ZooKeeper Service.
[root@ZYC3-AQGK-LJCL-SRV05 deployer]# systemctl status zookeeper
● zookeeper.service - ZooKeeper Service
 Loaded: loaded (/etc/systemd/system/zookeeper.service; enabled; vendor preset: disabled)
 Active: active (running) since Mon 2020-03-23 11:29:21 CST; 5s ago
 Docs: http://zookeeper.apache.org
 Process: 31011 ExecStop=/opt/zookeeper/zookeeper-prod/bin/zkServer.sh stop /opt/zookeeper/zookeeper-prod/conf/zoo.cfg (code=exited, status=0/SUCCESS)
 Process: 31129 ExecStart=/opt/zookeeper/zookeeper-prod/bin/zkServer.sh start /opt/zookeeper/zookeeper-prod/conf/zoo.cfg (code=exited, status=0/SUCCESS)
 Main PID: 31138 (java)
 CGroup: /system.slice/zookeeper.service
  └─31138 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /opt/zookeeper/zookeeper-prod/bin/../build/classes:/opt/zookeeper/zookeeper-prod/bin/../build/lib/*.jar:/opt/zookeeper/zoo...

Mar 23 11:29:20 ZYC3-AQGK-LJCL-SRV05 systemd[1]: Starting ZooKeeper Service...
Mar 23 11:29:20 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31129]: ZooKeeper JMX enabled by default
Mar 23 11:29:20 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31129]: Using config: /opt/zookeeper/zookeeper-prod/conf/zoo.cfg
Mar 23 11:29:21 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31129]: Starting zookeeper ... STARTED
Mar 23 11:29:21 ZYC3-AQGK-LJCL-SRV05 systemd[1]: Started ZooKeeper Service.
[root@ZYC3-AQGK-LJCL-SRV05 deployer]# systemctl status zookeeper
● zookeeper.service - ZooKeeper Service
 Loaded: loaded (/etc/systemd/system/zookeeper.service; enabled; vendor preset: disabled)
 Active: failed (Result: exit-code) since Mon 2020-03-23 11:29:26 CST; 706ms ago
 Docs: http://zookeeper.apache.org
 Process: 31225 ExecStop=/opt/zookeeper/zookeeper-prod/bin/zkServer.sh stop /opt/zookeeper/zookeeper-prod/conf/zoo.cfg (code=exited, status=0/SUCCESS)
 Process: 31129 ExecStart=/opt/zookeeper/zookeeper-prod/bin/zkServer.sh start /opt/zookeeper/zookeeper-prod/conf/zoo.cfg (code=exited, status=0/SUCCESS)
 Main PID: 31138 (code=exited, status=1/FAILURE)

Mar 23 11:29:20 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31129]: Using config: /opt/zookeeper/zookeeper-prod/conf/zoo.cfg
Mar 23 11:29:21 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31129]: Starting zookeeper ... STARTED
Mar 23 11:29:21 ZYC3-AQGK-LJCL-SRV05 systemd[1]: Started ZooKeeper Service.
Mar 23 11:29:26 ZYC3-AQGK-LJCL-SRV05 systemd[1]: zookeeper.service: main process exited, code=exited, status=1/FAILURE
Mar 23 11:29:26 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31225]: ZooKeeper JMX enabled by default
Mar 23 11:29:26 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31225]: Using config: /opt/zookeeper/zookeeper-prod/conf/zoo.cfg
Mar 23 11:29:26 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31225]: Stopping zookeeper ... /opt/zookeeper/zookeeper-prod/bin/zkServer.sh: 第 182 行:kill: (31138) - 没有那个进程
Mar 23 11:29:26 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[31225]: STOPPED
Mar 23 11:29:26 ZYC3-AQGK-LJCL-SRV05 systemd[1]: Unit zookeeper.service entered failed state.
Mar 23 11:29:26 ZYC3-AQGK-LJCL-SRV05 systemd[1]: zookeeper.service failed.

看到日志中提到/opt/zookeeper/zookeeper-prod/conf/zoo.cfg所以就去这个目录下看看有没有什么值得挖掘的内容。毕竟conf可以猜测是一个配置文件夹,讲道理应该是有log或者output之类的文件夹,里面存放着运行日志,特别是error日志,按照这个思路就可以进行相关的排查了。
之后发现/opt/zookeeper/zookeeper-prod/bin目录中有个zookeeper.out文件,这个是执行的细节,可以看下内容,然后cat一下,问题就很明朗了

2020-03-23 11:36:58,799 [myid:] - INFO [main:QuorumPeerConfig@136] - Reading configuration from: /opt/zookeeper/zookeeper-prod/bin/../conf/zoo.cfg
2020-03-23 11:36:58,814 [myid:] - INFO [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.153.115.26 to address: /10.153.115.26
2020-03-23 11:36:58,815 [myid:] - INFO [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.153.115.25 to address: /10.153.115.25
2020-03-23 11:36:58,816 [myid:] - INFO [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.153.115.24 to address: /10.153.115.24
2020-03-23 11:36:58,816 [myid:] - INFO [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.153.115.29 to address: /10.153.115.29
2020-03-23 11:36:58,816 [myid:] - INFO [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.153.115.28 to address: /10.153.115.28
2020-03-23 11:36:58,816 [myid:] - INFO [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.153.115.27 to address: /10.153.115.27
2020-03-23 11:36:58,816 [myid:] - WARN [main:QuorumPeerConfig@354] - Non-optimial configuration, consider an odd number of servers.
2020-03-23 11:36:58,816 [myid:] - INFO [main:QuorumPeerConfig@398] - Defaulting to majority quorums
2020-03-23 11:36:58,821 [myid:5] - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2020-03-23 11:36:58,821 [myid:5] - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 24
2020-03-23 11:36:58,822 [myid:5] - INFO [PurgeTask:DatadirCleanupManager$PurgeTask@138] - Purge task started.
2020-03-23 11:36:58,837 [myid:5] - INFO [PurgeTask:DatadirCleanupManager$PurgeTask@144] - Purge task completed.
2020-03-23 11:36:58,839 [myid:5] - INFO [main:QuorumPeerMain@130] - Starting quorum peer
2020-03-23 11:36:58,849 [myid:5] - INFO [main:ServerCnxnFactory@117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2020-03-23 11:36:58,856 [myid:5] - INFO [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
2020-03-23 11:36:58,861 [myid:5] - INFO [main:QuorumPeer@1158] - tickTime set to 2000
2020-03-23 11:36:58,861 [myid:5] - INFO [main:QuorumPeer@1204] - initLimit set to 10
2020-03-23 11:36:58,861 [myid:5] - INFO [main:QuorumPeer@1178] - minSessionTimeout set to -1
2020-03-23 11:36:58,862 [myid:5] - INFO [main:QuorumPeer@1189] - maxSessionTimeout set to -1
2020-03-23 11:36:58,871 [myid:5] - INFO [main:QuorumPeer@1467] - QuorumPeer communication is not secured!
2020-03-23 11:36:58,871 [myid:5] - INFO [main:QuorumPeer@1496] - quorum.cnxn.threads.size set to 20
2020-03-23 11:36:58,872 [myid:5] - INFO [main:FileSnap@86] - Reading snapshot /data/zookeeper/data/version-2/snapshot.b91d0000003c
2020-03-23 11:36:59,290 [myid:5] - ERROR [main:QuorumPeer@692] - Unable to load database on disk
java.io.IOException: The accepted epoch, ba86 is less than the current epoch, ba87
 at org.apache.zookeeper.server.quorum.QuorumPeer.loadDataBase(QuorumPeer.java:689)
 at org.apache.zookeeper.server.quorum.QuorumPeer.start(QuorumPeer.java:635)
 at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:170)
 at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:114)
 at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:81)
2020-03-23 11:36:59,292 [myid:5] - ERROR [main:QuorumPeerMain@92] - Unexpected exception, exiting abnormally
java.lang.RuntimeException: Unable to run quorum server 
 at org.apache.zookeeper.server.quorum.QuorumPeer.loadDataBase(QuorumPeer.java:693)
 at org.apache.zookeeper.server.quorum.QuorumPeer.start(QuorumPeer.java:635)
 at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:170)
 at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:114)
 at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:81)
Caused by: java.io.IOException: The accepted epoch, ba86 is less than the current epoch, ba87
 at org.apache.zookeeper.server.quorum.QuorumPeer.loadDataBase(QuorumPeer.java:689)
 ... 4 more

日志中写着,正在读取zk的快照,然后就报错了,无法载入磁盘上的数据库,那么!我就把快照删了snapshot.b91d0000003c,让其自己重新生成快照文件,完事了。

2020-03-23 11:36:58,872 [myid:5] - INFO [main:FileSnap@86] - Reading snapshot /data/zookeeper/data/version-2/snapshot.b91d0000003c
2020-03-23 11:36:59,290 [myid:5] - ERROR [main:QuorumPeer@692] - Unable to load database on disk

酸爽

[root@ZYC3-AQGK-LJCL-SRV05 deployer]# systemctl status zookeeper
● zookeeper.service - ZooKeeper Service
 Loaded: loaded (/etc/systemd/system/zookeeper.service; enabled; vendor preset: disabled)
 Active: active (running) since Mon 2020-03-23 12:12:08 CST; 5min ago
 Docs: http://zookeeper.apache.org
 Process: 25348 ExecStop=/opt/zookeeper/zookeeper-prod/bin/zkServer.sh stop /opt/zookeeper/zookeeper-prod/conf/zoo.cfg (code=exited, status=0/SUCCESS)
 Process: 25658 ExecStart=/opt/zookeeper/zookeeper-prod/bin/zkServer.sh start /opt/zookeeper/zookeeper-prod/conf/zoo.cfg (code=exited, status=0/SUCCESS)
 Main PID: 25667 (java)
 CGroup: /system.slice/zookeeper.service
  └─25667 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /opt/zookeeper/zookeeper-prod/bin/../build/classes:/opt/zookeeper/zookeeper-prod/bin/../build/lib/*.jar:/opt/zookeeper/zoo...

Mar 23 12:12:07 ZYC3-AQGK-LJCL-SRV05 systemd[1]: Starting ZooKeeper Service...
Mar 23 12:12:07 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[25658]: ZooKeeper JMX enabled by default
Mar 23 12:12:07 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[25658]: Using config: /opt/zookeeper/zookeeper-prod/conf/zoo.cfg
Mar 23 12:12:08 ZYC3-AQGK-LJCL-SRV05 zkServer.sh[25658]: Starting zookeeper ... STARTED
Mar 23 12:12:08 ZYC3-AQGK-LJCL-SRV05 systemd[1]: Started ZooKeeper Service.

因为zk每次运行的时候都会有个一快照文件,这个是状态恢复用的,由于这台主机之前磁盘满了,导入zk无法及时写入消息,之后我们将设备进行重启,应该就是这个时候,快照文件写入失败导致的。不过这个也不是万能解法,也是要具体问题具体分析,因为在集群中,把快照文件删了,后续想恢复数据库状态就难了,不过幸亏我们的zk是6节点的,另外五个节点正常,所以这么操作是允许的。
至此收工:)

由于无法读取database,zookeeper启动失败

标签:war   system   dep   ocs   重启   RoCE   vendor   ror   exe   

热心网友 时间:2022-04-11 07:43

1 保证zookeeper正常启动 
启动zookeeper(换行处键入回车)

cd zookeeper-3.4.6 cd bin ./zkServer.sh start 启动 ./zkServer.sh status 查看状态1234

启动成功的提示: 

如果提示Starting zookeeper … already running as process ……,表示之前有启动过zookeeper,但是没有正常关闭。 
进入和bin同层级的data目录下,删除zookeeper_server.pid文件,再执行启动命令。

cd .. 退回上级目录 cd data rm -f zookeeper_server.pid cd .. cd bin ./zkServer.sh start123456

目录结构: 


2 启动远程 192.168.37.138 上的Tomcat

cd apache-tomcat-7.0.47 cd bin ./shutdown.sh 如果之前启动了Tomcat,就先关闭进程 ./startup.sh 启动Tomcat1234

3 保证本机可以远程访问bbo监控界面,并且能够看到服务的提供者和消费者。(需要安装bbo监控中心) 
本机 192.168.37.159 
远程 192.168.37.138 
在浏览器访问http://192.168.37.138:8080/bbo-admin/ 
弹出窗口,要求输入用户名密码(都是root)



如果提供者(e3-manager)和消费者(e3-manager-web)只显示一方,说明未显示的一方对应的工程启动失败,需要去代码中检查。

注意:zookeeper没有启动成功的报错在项目运行的日志里一般看不到,需要在src/main/resources目录下添加log4j.properties 后,才能在控制台看到相应的报错信息。

log4j.properties

log4j.rootLogger=DEBUG,A1 log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
微信全部历史头像怎么看?微信查看全部历史头像教程 微信怎么查看历史头像_历史头像查看方法[多图] ...商云供应链协同系统的优势能力,打造医疗器械行业数字化转型新生态... 医疗器械企业为什么要转型数字化? 中国医疗器械行业网网站简介 中国医疗器械交易网网站介绍 中国医疗器械行业网经营理念 电热毯开着睡觉对人体有害吗-电热毯开着睡觉有什么影响 日常保养皮质包包的方法有哪些? 如何保养真皮包包?需要注意什么? 如何禁用zookeeper中acl权限 如何解决 ambari 的单点问题 zookeeper watch怎么查看 zookeeper集群搭建的时候,windows系统的防火墙要关闭吗 zookeeper 集群 部署好后怎么使用 java hbase伪分布式怎么配置eclipse zookeeper.out 怎么退出监控 如何关闭org.apache.zookeeper.clientcnxn的debug日志 zookeeper怎么分发任务的 springmvc dubbo zookeeper怎么关掉日志 zookeeper关闭时抛出异常?为啥? windows 下zookeeper怎样关闭进程 怎么把华为通讯录导入苹果手机 华为怎么把通讯录导入苹果手机 华为的通讯录怎么导入iphone 期货K线和股票的K线从结构上讲要注意什么 期货交易中盈亏比分析日k和月k不一致,应该服从哪一个? 期货K图的分析经典 什么是期货的k,d值怎么表示。谢谢! 期货KDJ是什么意思?K是代表什么?D代表什么?J代表什么? zookeeper 关联的字符串 什么用 如何使用Java API读写Hbase 梦见妹妹的钱被偷了我发现了,小偷被我捉住了 梦见妹妹把钱丢了,我们又糟到绑架 梦到闺蜜丢钱是什么意思 梦到兄弟姐妹家钱被偷 梦见自己跟妹妹的钱包丢了,但自己的却是失而复得 梦见妹妹的钱被偷了7800元 梦见人坏人抢自己妹妹,我找妹妹钱被偷,我哭了? 周公解梦:梦见把妹妹口袋里的大面值钱都拿走了? 梦见妹妹偷钱,我打她拉她,被追到看房子里,是什么预兆? vivo手机怎么强制解锁? 如何知道淘宝店铺卖家的发货地址,而且卖家还不知道?急用谢谢 淘宝看不到发货地址 淘宝客服可以查到卖家发货地址吗 怎么查询淘宝卖家给自己发货的地址? 如何鉴别淘宝上卖家真正发货地 华师网院的考试形式不包括什么?a笔试b闭卷 c开卷d考查 法考的考试形式是什么啊分几个科目呢? Adobe世界大赛的考试形式和考试内容是什么样的?有人考过吗?