標籤:內容 tick init strong ntp 介面 參考 director target
概述
ZooKeeper是Hadoop的正式子項目,它是一個針對大型分布式系統的可靠協調系統,提供的功能包括:配置維護、名字服務、分布式同步、組服務等。ZooKeeper的目標就是封裝好複雜易出錯的關鍵服務,將簡單易用的介面和效能高效、功能穩定的系統提供給使用者。
安裝&配置
在apache的官方網站提供了好多鏡像,然後找到對應的版本,此處用的是3.3.6
:
https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/
把下載的zookeeper的檔案解壓到指定目錄:D:\machine\zookeeper-3.3.6
修改conf下增加一個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 anacknowledgement
syncLimit=5
# the directory where the snapshot isstored. //鏡像資料位元置
dataDir=D:\\data\\zookeeper
#日誌位置
dataLogDir=D:\\logs\\zookeeper
# the port at which the clients willconnect 用戶端串連的連接埠
clientPort=2181
進入到bin目錄,並且啟動zkServer.cmd,這個指令碼中會啟動一個Java進程
D:\machine\zookeeper-3.3.6>cd bin
D:\machine\zookeeper-3.3.6\bin>
D:\machine\zookeeper-3.3.6\bin >zkServer.cmd
啟動後jps可以看到QuorumPeerMain的進程
D:\machine\zookeeper-3.3.6\bin >jps
啟動用戶端運行查看一下
D:\machine\zookeeper-3.3.6\bin>zkCli.cmd -server 127.0.0.1:2181
這個時候zookeeper已經安裝成功了。
參考官方文檔:
http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html
一下叢集設定我沒有試,從別處拷貝而來,有興趣的可以試試:
參考單機模式、叢集和偽叢集的文章
http://sqcjy111.iteye.com/blog/1741320
在 一台機器上通過偽叢集運行時可以修改 zkServer.cmd 檔案在裡面加入
set ZOOCFG=..\conf\zoo1.cfg 這行,另存新檔 zkServer-1.cmd
如果有多個可以以此類推
還需要 在對應的
/tmp/zookeeper/1,
/tmp/zookeeper/2,
/tmp/zookeeper/3
建立一個文字檔命名為myid,內容就為對應的zoo.cfg裡server.後數字
ZooKeeper安裝(Windows)