【Zookeeper】Win平臺偽叢集搭建
阿新 • • 發佈:2022-03-04
下載穩定版Zookeeper
https://downloads.apache.org/zookeeper/stable/
GZ包:
apache-zookeeper-3.6.3-bin.tar.gz
解壓一份到本地磁碟中
1、將conf目錄下的zoo_sample.cfg複製一份改名為zoo.cfg
2、更改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:\\develop\\ZookeeperCluster\\apache-zookeeper-3.5.9-2\\data # the port atwhich the clients will connect clientPort=2182 # 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 server.1 = 127.0.0.1:2184:3887 server.2 = 127.0.0.1:2185:3888 server.3 = 127.0.0.1:2186:3889
由於是在一臺機器上部署三個Zookeeper例項,必然佔用系統很多埠資源
每個例項的客戶埠不能一致,服務埠和選舉埠也不能一致
1個例項佔用 3個埠 (客戶埠 + 服務埠 + 選舉埠)
然後把Zookeeper的目錄複製2份出來,分別重新命名以區分
apache-zookeeper-3.5.9-1 apache-zookeeper-3.5.9-2 apache-zookeeper-3.5.9-3
寫入服務ID標識
ECHO 1 > apache-zookeeper-3.5.9-1\ZookeeperCluster\apache-zookeeper-3.5.9-1\data\myid ECHO 2 > apache-zookeeper-3.5.9-1\ZookeeperCluster\apache-zookeeper-3.5.9-2\data\myid ECHO 3 > apache-zookeeper-3.5.9-1\ZookeeperCluster\apache-zookeeper-3.5.9-3\data\myid
更改apache-zookeeper-3.5.9-2 的zoo.cfg 客戶端埠為 2182
更改apache-zookeeper-3.5.9-3 的zoo.cfg 客戶端埠為 2183
clientPort=2181 clientPort=2182 clientPort=2183
為了方便啟動,可以編寫叢集啟動指令碼:
@ECHO OFF start %CD%\apache-zookeeper-3.5.9-1\bin\zkServer.cmd start %CD%\apache-zookeeper-3.5.9-2\bin\zkServer.cmd start %CD%\apache-zookeeper-3.5.9-3\bin\zkServer.cmd