天天看點

Windows環境下安裝和配置Zookeeper環境及常見錯誤解決方案1.下載下傳Zookeeper安裝檔案2.解壓縮3.修改配置檔案4. 啟動Zookeeper5. Zookeeper啟動驗證常見錯誤及解決方案

1.下載下傳Zookeeper安裝檔案

Zookeeper下載下傳位址:

https://downloads.apache.org/zookeeper/

根據自己的需求,找到對應的版本下載下傳即可。

Windows環境下安裝和配置Zookeeper環境及常見錯誤解決方案1.下載下傳Zookeeper安裝檔案2.解壓縮3.修改配置檔案4. 啟動Zookeeper5. Zookeeper啟動驗證常見錯誤及解決方案

本文以最新版3.7.0為例,進入3.7.0所在目錄,點選下載下傳bin.tar.gz檔案

注意:從目前的最新版本3.5.5開始,帶有bin名稱的包才是我們想要的下載下傳可以直接使用的裡面有編譯後的二進制的包,而之前的普通的tar.gz的包裡面是隻是源碼的包無法直接使用

備用下載下傳位址:

https://wwe.lanzouo.com/b01ixumsd

 (密碼:5tx8)

Windows環境下安裝和配置Zookeeper環境及常見錯誤解決方案1.下載下傳Zookeeper安裝檔案2.解壓縮3.修改配置檔案4. 啟動Zookeeper5. Zookeeper啟動驗證常見錯誤及解決方案

2.解壓縮

将下載下傳的tar.gz壓縮檔案解壓至自己常用的目錄中,本文章以解壓中C://APP/Zookeeper下為例進行講解。

解壓完成後,在Zookeeper目錄下建立data目錄用于存放資料檔案,目錄結構如下:

Windows環境下安裝和配置Zookeeper環境及常見錯誤解決方案1.下載下傳Zookeeper安裝檔案2.解壓縮3.修改配置檔案4. 啟動Zookeeper5. Zookeeper啟動驗證常見錯誤及解決方案

3.修改配置檔案

進入Zookeeper的conf目錄,将zoo_sample.cfg複制一份并重命名為zoo.cfg

打開該配置檔案修改其中的内容

主要修改的内容包括兩項:data檔案目錄 和 Zookeeper端口号

注意:dataDir參數不要使用/tmp來做存儲快照的目錄,/tmp這隻是一個案例。
Windows環境下安裝和配置Zookeeper環境及常見錯誤解決方案1.下載下傳Zookeeper安裝檔案2.解壓縮3.修改配置檔案4. 啟動Zookeeper5. Zookeeper啟動驗證常見錯誤及解決方案
Zookeeper配置檔案詳解
# The number of milliseconds of each tick
#CS通信心跳時間,機關是毫秒,系統預設是2000毫秒,即間隔兩秒心跳一次。
#tickTime的意義:用戶端與伺服器或者伺服器與伺服器之間維持心跳,也就是每個tickTime時間就會發送一次心跳。
#通過心跳不僅能夠用來監聽機器的工作狀态,還可以通過心跳來控制Flower跟Leader的通信時間,預設情況下FL的會話時常是心跳間隔的兩倍。
tickTime=2000
# The number of ticks that the initial synchronization phase can take
#叢集中的follower伺服器(F)與leader伺服器(L)之間初始連接配接時能容忍的最多心跳數(tickTime的數量)。
initLimit=10
# The number of ticks that can pass between sending a request and getting an acknowledgement
#叢集中flower伺服器(F)跟leader(L)伺服器之間的請求和答應最多能容忍的心跳數。
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just example sakes.
#資料檔案存放的目錄,主要用來存放myid資訊跟一些版本,日志,跟伺服器唯一的ID資訊等。
#不要使用/tmp來做存儲快照的目錄,/tmp這隻是一個案例。
dataDir=../data
# the port at which the clients will connect
#用戶端連接配接的接口,用戶端連接配接zookeeper伺服器的端口,zookeeper會監聽這個端口,接收用戶端的請求通路!預設是2181。
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
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
           

4. 啟動Zookeeper

切換目錄至bin目錄下,在位址欄中輸入cmd進入指令行界面zkServer.cmd并回車即可啟動Zookeeper

Windows環境下安裝和配置Zookeeper環境及常見錯誤解決方案1.下載下傳Zookeeper安裝檔案2.解壓縮3.修改配置檔案4. 啟動Zookeeper5. Zookeeper啟動驗證常見錯誤及解決方案

當出現如下提示時,代表Zookeeper啟動成功

Windows環境下安裝和配置Zookeeper環境及常見錯誤解決方案1.下載下傳Zookeeper安裝檔案2.解壓縮3.修改配置檔案4. 啟動Zookeeper5. Zookeeper啟動驗證常見錯誤及解決方案

5. Zookeeper啟動驗證

在指令行界面輸入 zkCli.cmd可以進入Zookeeper用戶端工具

在指令号中輸入 create -e /test 123456 和 get /test可以建立和檢視資料資訊

Windows環境下安裝和配置Zookeeper環境及常見錯誤解決方案1.下載下傳Zookeeper安裝檔案2.解壓縮3.修改配置檔案4. 啟動Zookeeper5. Zookeeper啟動驗證常見錯誤及解決方案

常見錯誤及解決方案

1.錯誤:找不到或無法加載主類org.apache.zookeeper.server.quorum.QuorumPeerMain

下載下傳對應的bin版本的安裝包即可

https://developer.aliyun.com/article/831767