剛學習Zookeper時大多數都是直接在windows環境下安裝,本文主要介紹Zookeper安裝啟動及注意事項,由于Zookeper需要在java環境運行,啟動之前配置好java環境變數
1.下載Zookeper
鏈接:https://pan.baidu.com/s/1tsU3-FI0_k48e9dBY0TDmQ
提取碼:t2nn
2.解壓檔案到本地,一下為Zookeper檔案目錄

3.創建data、log兩個檔案夾用于存盤資料與日志資訊

4.進入conf檔案復制zoo_sample.cfg并命名為zoo.cfg

5.zoo.cfg默認配置為一下資訊
# 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
# 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
6 編輯配置資訊,修改dataDir的值,指向剛才創建的data檔案夾,同時創建一個dataLogDir,指向上一次創建的log檔案夾,修改后為
# 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/development/zookeeper-3.4.12/zookeeper-3.4.12/data
dataLogDir=D:/development/zookeeper-3.4.12/zookeeper-3.4.12/log
#####################################################
# 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
兩次對比


7.進入Zookeper主目錄下打開bin目錄,會看到以下檔案

zkServer.cmd為windows環境下服務端啟動命令
編輯zkServer.cmd,需要修改啟動命令,下面為啟動腳本,直接啟動DOS會直接閃退,因為這個腳本需要做一些修改

a)在結尾之前需要指定Zookeper組態檔路徑,我的路徑配置如下,只需要將路徑改為對應的zoo.cfg路徑
set ZOOCFG=D:/development/zookeeper-3.4.12/zookeeper-3.4.12/conf/zoo.cfg

b)啟動依然報錯,添加一個暫停,啟動zkServer.cmd查看錯誤資訊


日志提示是因為Zookeper需要在環境變數中配置JAVA變數,可能很多人直接將path中添加的環境,這樣 call ‘%jJAVA%’ 找不到對應的變數值,直接將call "%JAVA%"改成java,直接執行java命令,這樣只要配置了java環境變數就可使用


執行server啟動腳本,出現以下畫面,則Zookeper啟動完成

8.啟動客戶端,若出現閃退,修改腳本

9.啟動客戶端,Zookeper安裝啟動完成

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/37322.html
標籤:其他
上一篇:關于第一個專案cms心得
