官網下載地址:https://archive.apache.org/dist/zookeeper/zookeeper-3.6.1/apache-zookeeper-3.6.1-bin.tar.gz
Zookeeper安裝需要基於java的jdk環境,jdk安裝這里不再詳細描述,網上安裝方法可以自己查詢下,測試jdk是否安裝成功cmd命令 java -version
文件下載成功后解壓到自己指定的分區中,我是解壓到D盤,進入解壓目錄的conf中,復制zoo_sample.cfg一份並修改名字為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=D:\\apache-zookeeper-3.6.1-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
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
- tickTime:這個時間是作為 Zookeeper 服務器之間或客戶端與服務器之間維持心跳的時間間隔,也就是每個 tickTime 時間就會發送一個心跳。
- dataDir:顧名思義就是 Zookeeper 保存數據的目錄,默認情況下,Zookeeper 將寫數據的日志文件也保存在這個目錄里。
- clientPort:這個端口就是客戶端連接 Zookeeper 服務器的端口,Zookeeper 會監聽這個端口,接受客戶端的訪問請求。
修改完配置后,可以執行bin目錄中的zkServer.cmd腳本 ,如執行后cmd窗口閃退,可以再末尾添加 pause命令,可以查看具體錯誤原因。
如執行后報錯誤:找不到或無法加載主類 org.apache.zookeeper.server.quorum.QuorumPeerMain,是由於從版本3.5.5開始,帶有bin名稱的包才是我們想要的下載可以直接使用的里面有編譯后的二進制的包,而之前的普通的tar.gz的包里面是只是源碼的包無法直接使用。
安裝成功后效果圖