20190311 Windows安裝ZooKeeper

1. 說明

記錄過程當中踩過的坑html

1.1. 環境

  • 本機環境:Win10
  • ZooKeeper版本:3.4.6

2. 安裝

2.1. 下載

官網下載網址java

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

啓動命令:apache

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

啓動無異常信息session

  1. 客戶端鏈接,驗證啓動成功

客戶端鏈接命令:socket

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

命令行窗口顯示:ui

[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)

查詢報錯,由於是剛安裝的,因此確認不會有什麼問題,重啓過服務以後再次嘗試,響應正常code

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

參考資料

Apache ZooKeeper
Windows安裝和使用zookeeperorm

相關文章
相關標籤/搜索