20190311 Windows安装ZooKeeper

1. 说明

记录过程中踩过的坑

1.1. 环境

  • 本机环境:Win10
  • ZooKeeper版本:3.4.6

2. 安装

2.1. 下载

官网下载网址

2.2. 修改配置文件

  1. 复制conf目录下的zoo_sample.cfg,修改名称为zoo.cfg
  2. 按照本机安装路径修改zoo.cfg配置文件
dataDir=E:\\Develop\\zookeeper\\3.4.6\\zookeeper-3.4.6\\data
dataLogDir=E:\\Develop\\zookeeper\\3.4.6\\zookeeper-3.4.6\\log
  1. 新建data和log文件夹,否则报错,报错信息为
PS E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6> .\bin\zkServer.cmd

E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6>java "-Dzookeeper.log.dir=E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\bin\.." "-Dzookeeper.root.logger=INFO,CONSOLE" -cp "E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\bin\..\build\classes;E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\bin\..\build\lib\*;E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\bin\..\*;E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\bin\..\lib\*;E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\bin\..\conf\zoo.cfg"
2019-03-11 14:00:09,828 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\bin\..\conf\zoo.cfg
2019-03-11 14:00:09,834 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\bin\..\conf\zoo.cfg
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:123)
        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: dataLogDir E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6\log is missing.
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:253)
        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:119)
        ... 2 more
Invalid config, exiting abnormally

E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6>endlocal
  1. 启动ZooKeeper

启动命令:

PS E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6> .\bin\zkServer.cmd

启动无异常信息

  1. 客户端连接,验证启动成功

客户端连接命令:

PS E:\Develop\zookeeper\3.4.6\zookeeper-3.4.6> .\bin\zkCli.cmd -server 127.0.0.1:2181

命令行窗口显示:

[zk: 127.0.0.1:2181(CONNECTING) 0]

进行查询操作:

ls /
2019-03-11 14:26:11,279 [myid:] - INFO  [main-SendThread(0:0:0:0:0:0:0:1:2181):ClientCnxn$SendThread@1096] - Client session timed out, have not heard from server in 15001ms for sessionid 0x0, closing socket connection and attempting reconnect
Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
        at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1472)
        at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1500)
        at org.apache.zookeeper.ZooKeeperMain.processZKCmd(ZooKeeperMain.java:720)
        at org.apache.zookeeper.ZooKeeperMain.processCmd(ZooKeeperMain.java:588)
        at org.apache.zookeeper.ZooKeeperMain.executeLine(ZooKeeperMain.java:360)
        at org.apache.zookeeper.ZooKeeperMain.run(ZooKeeperMain.java:323)
        at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:282)

查询报错,因为是刚安装的,所以确认不会有什么问题,重启过服务之后再次尝试,响应正常

[zk: localhost:2181(CONNECTED) 1] ls /
[zookeeper]

参考资料

Apache ZooKeeper
Windows安装和使用zookeeper

posted @ 2019-03-11 14:58  流星<。)#)))≦  阅读(616)  评论(0编辑  收藏  举报