关于在windows下启动zkServer.cmd闪退的解决办法

符号 阅读:857 2021-03-31 21:34:30 评论:0

1. 下载zookeeper注册中心,下载地址:http://www.apache.org/dyn/closer.cgi/zookeeper/  下载后解压即可,进入D:\apach-zookeeper-3.4.5\bin,

双击zkServer.cmd启动注册中心服务。

双击 zkServer.cmd,发现dos框一闪而过,无法正确启动zookeeper。



右键编辑   zkServer.cmd

@echo off 
REM Licensed to the Apache Software Foundation (ASF) under one or more 
REM contributor license agreements.  See the NOTICE file distributed with 
REM this work for additional information regarding copyright ownership. 
REM The ASF licenses this file to You under the Apache License, Version 2.0 
REM (the "License"); you may not use this file except in compliance with 
REM the License.  You may obtain a copy of the License at 
REM 
REM     http://www.apache.org/licenses/LICENSE-2.0 
REM 
REM Unless required by applicable law or agreed to in writing, software 
REM distributed under the License is distributed on an "AS IS" BASIS, 
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
REM See the License for the specific language governing permissions and 
REM limitations under the License. 
 
setlocal 
call "%~dp0zkEnv.cmd" 
 
set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain 
echo on 
java "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %* 
 
endlocal 
  
pause 
在末尾输入pause ,保存退出


再次运行zkServer.cmd,发现dos命令行窗口静止了。发现如下错误信息:

2017-01-09 18:59:39,529 ERROR org.apache.zookeeper.server.quorum.QuorumPeer: Unable to load database on disk 
java.io.IOException: Failed to process transaction type: 1 error: KeeperErrorCode = NoNode for /cloudera_manager_zookeeper_canary 
        at org.apache.zookeeper.server.persistence.FileTxnSnapLog.restore(FileTxnSnapLog.java:188) 
        at org.apache.zookeeper.server.ZKDatabase.loadDataBase(ZKDatabase.java:223) 
        at org.apache.zookeeper.server.quorum.QuorumPeer.loadDataBase(QuorumPeer.java:417) 
        at org.apache.zookeeper.server.quorum.QuorumPeer.start(QuorumPeer.java:409) 
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:156) 
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116) 
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:79) 
Caused by: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /cloudera_manager_zookeeper_canary 
        at org.apache.zookeeper.server.persistence.FileTxnSnapLog.processTransaction(FileTxnSnapLog.java:250) 
        at org.apache.zookeeper.server.persistence.FileTxnSnapLog.restore(FileTxnSnapLog.java:186)
解决办法:

删除zookeeper 配置的数据目录文件夹

# 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=/tmp/zookeeper 
# the port at which the clients will connect 
clientPort=2181 
# 
# 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 
# Purge task interval in hours 
# Set to "0" to disable auto purge feature 
#autopurge.purgeInterval=1

初始化数据目录

重启





声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号