windows10環境搭建zookeeper集羣

windows10環境搭建zookeeper集羣

今天嘗試在自己的windows系統中搭建zokeeper集羣環境,記錄下步驟和出現的問題以及解決方法。

搭建環境

1)電腦裏下載的zookeeper版本是3.4.5,解壓到D盤,創建3個目錄,分別爲server1,servr2,server3,將解壓好的文件分別複製一份到這三個目錄中。

2)配置。進入到conf目錄中,將zoo_sample.cfg重命名爲zoo.cfg,並且修改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:/DataBase/zookeeper/server1/zookeeper-3.4.5/data
# the port at which the clients will connect
clientPort=2181
server.1=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889

其中,dataDir可以自己選擇目錄,是存放myid文件的地方,data文件夾需要自己創建,其他的兩個文件夾的配置也要修改,server2文件夾裏面的clientPort就可以寫成2182,dataDir也需要相對應修改,依次類推。

3)進入server1文件夾裏面的zookeeper文件夾裏,創建data文件夾,並且創建myid文件。

注意,這塊需要保證文件的編碼格式,我是直接在目錄裏使用鼠標直接右鍵生成文件,最後報錯了。想到直接在cmd進入到data文件夾裏,使用echo命令創建,這樣就可以創建好了,最後還得看看是否myid文件裏只有這個一個數字(空格,換行之類的都不行),其他兩個文件夾也一樣。

echo 1 > myid

4)進入到bin文件夾裏,shift + 右擊,進入控制檯,啓動zookeeper,啓動三個

zkServer.cmd

5)啓動成功後,進入到server1的bin目錄下,連接,連接其他的就進入到相對應的文件夾裏

zkCli.cmd

6)使用set ,ls ,get命令進行測試。在server1中set的數據在server2或者server3中同樣可以看到,保證了同步。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章