2.Apache-Zookeeper安装运行

1. 下载

在官方网站 https://www.apache.org/dyn/closer.cgi/zookeeper/ 下载zookeeper压缩包

2. 解压安装

3. 修改配置文件

直接运行会报错

D:\apache-zookeeper-3.5.5-bin\bin>call "D:\Program Files\Java\jdk1.8.0_211"\bin\java "-Dzookeeper.log.dir=D:\apache-zookeeper-3.5.5-bin\bin\..\logs" "-Dzookeeper.root.logger=INFO,CONSOLE" "-Dzookeeper.log.file=zookeeper-suman-server-DESKTOP-SM368S7.log" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%p /t /f" -cp "D:\apache-zookeeper-3.5.5-bin\bin\..\build\classes;D:\apache-zookeeper-3.5.5-bin\bin\..\build\lib\*;D:\apache-zookeeper-3.5.5-bin\bin\..\*;D:\apache-zookeeper-3.5.5-bin\bin\..\lib\*;D:\apache-zookeeper-3.5.5-bin\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "D:\apache-zookeeper-3.5.5-bin\bin\..\conf\zoo.cfg"
2019-07-14 23:44:29,290 [myid:] - INFO  [main:QuorumPeerConfig@133] - Reading configuration from: D:\apache-zookeeper-3.5.5-bin\bin\..\conf\zoo.cfg
2019-07-14 23:44:29,295 [myid:] - ERROR [main:QuorumPeerMain@89] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing D:\apache-zookeeper-3.5.5-bin\bin\..\conf\zoo.cfg
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:154)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:113)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:82)
Caused by: java.lang.IllegalArgumentException: D:\apache-zookeeper-3.5.5-bin\bin\..\conf\zoo.cfg file is missing
        at org.apache.zookeeper.server.util.VerifyingFileFactory.doFailForNonExistingPath(VerifyingFileFactory.java:51)
        at org.apache.zookeeper.server.util.VerifyingFileFactory.validate(VerifyingFileFactory.java:45)
        at org.apache.zookeeper.server.util.VerifyingFileFactory.create(VerifyingFileFactory.java:40)
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:139)
        ... 2 more
Invalid config, exiting abnormally

这个错误是因为 zookeeper启动的时候会调用zkEnv里的环境变量,里面的conf文件已经指定了,但是conf文件夹中并没有配置好的文件。

下面有两个方案,修改zkEnv.cmd或者在conf中创建zoo.cfg,这儿我们选择第二种,复制一份zoo_sample.conf为zoo.conf

配置文件节选

···
set ZOOCFGDIR=%~dp0%..\conf
···
set ZOOCFG=%ZOOCFGDIR%\zoo.cfg
···

修改后继续报错

java.io.IOException: No snapshot found, but there are log entries. Something is broken!
        at org.apache.zookeeper.server.persistence.FileTxnSnapLog.restore(FileTxnSnapLog.java:211)
        at org.apache.zookeeper.server.ZKDatabase.loadDataBase(ZKDatabase.java:240)
        at org.apache.zookeeper.server.ZooKeeperServer.loadData(ZooKeeperServer.java:290)
        at org.apache.zookeeper.server.ZooKeeperServer.startdata(ZooKeeperServer.java:450)
        at org.apache.zookeeper.server.NIOServerCnxnFactory.startup(NIOServerCnxnFactory.java:764)
        at org.apache.zookeeper.server.ServerCnxnFactory.startup(ServerCnxnFactory.java:98)
        at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:144)
        at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:106)
        at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:64)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:128)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:82)

这是因为dataDir配置存在问题的原因

在zookeeper目录下新建data目录,并修改zoo.cfg文件夹中的路径

dataDir=D:/apache-zookeeper-3.5.5-bin/data

4. 运行zookeeper

双击zkServer.cmd 启动 zookeeper

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值