1. 程式人生 > 實用技巧 >Windows環境下Zookeeper的安裝及啟動

Windows環境下Zookeeper的安裝及啟動

一、下載及安裝配置 JDK (Kafka依賴於Zookeeper服務,而Zookeeper的運營依賴JDK)

1.地址:https://www.oracle.com/java/technologies/javase-jdk14-downloads.html

下載windows可執行檔案,直接點選安裝,預設下一步,直到完成安裝。

2.配置JDK

我的電腦 --> 右鍵 ---> 屬性 --> 高階系統設定 -- > 環境變數

新增 JAVA_HOME變數:C:\Program Files\Java\jdk-14.0.2

新增 CLASSPATH變數:%JAVA_HOME%\lib

在PATH變數中加入:%JAVA_HOME%\bin

開啟CMD,驗證JDK是否安裝成功

二、下載安裝配置Zookeeper服務

1.地址:https://mirror-hk.koddos.net/apache/zookeeper/stable/

2.修改配置檔案:conf資料夾,在裡面複製一份zoo_sample.cfg並重命名為zoo.cfg檔案。

(這裡我主要修改了日誌儲存地址:dataDir)

# 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=D:\\AmandaSoft\\apache-zookeeper-3.5.8-bin\\data # the port at which the clients will connect clientPort
=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # 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.tickTime:這個時間是作為 zookeeper 伺服器之間或客戶端與伺服器之間維持心跳的時間間隔,也就是每個 tickTime 時間就會發送一個心跳。
  2.dataDir:顧名思義就是 zookeeper 儲存資料的目錄,預設情況下,Zookeeper 將寫資料的日誌檔案也儲存在這個目錄裡。
  3.clientPort:這個埠就是客戶端連線 zookeeper 伺服器的埠,Zookeeper 會監聽這個埠,接受客戶端的訪問請求。

3.進入..\apache-zookeeper-3.5.8-bin\bin目錄

會出現以下很長一段:可以看到QuorumPeerMain的程序

可通過雙擊zkCli.cmd啟動客戶端