zookeeper 官網: 現在最新版本是 3.4.6 ,但是這個版本我沒有執行起來,可能是那配置出現問題了,現在我用的是3.4.5
環境:windows 8.1 、zookeeper3.4.5
現在要做的是 單機偽集群(木有辦法 沒有那麼多機器啊)
修改配置檔案,在conf中
將zoo_sample.cfg檔案複製乙個重新命名為zoo.cfg
修改zoo.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=/tmp/zookeeper
# the port at which the clients will connect
clientport=2181
## be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
## 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
修改後:
# 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=e:/zookeepercluster/servcer001/data
datalogdir=e:/zookeepercluster/servcer001/logs
# the port at which the clients will connect
clientport=2181
## be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
## 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=localhost:8881:7771
server.2=localhost:8882:7772
#server.3=192.168.192.7:8883:7773
#server.4=192.168.192.7:8884:7774
#server.5=192.168.192.7:8885:7775
主要是在下邊新增幾個伺服器的ip位址,因為我的都是本機,所以我這都是一樣的位址。
引數解釋:
3. 在data下面建立乙個myid檔案,內容為1
這個內容對應的是這個zookeeper的順序,第乙個zookeeper就是1,第二個zookeeper就是2,沒有先後順序,只是不能重複。
這個最好是和 server.x 中的x對應
依次修改配置檔案 簡歷server02,server03,server04節點 目錄結構如下:
├── server001
│ ├── data
│ ├── logs
│ └── zookeeper-3.4.5
├── server002
│ ├── data
│ ├── logs
│ └── zookeeper-3.4.5
├── server003
│ ├── data
│ ├── logs
│ └── zookeeper-3.4.5
├── server004
│ ├── data
│ ├── logs
│ └── zookeeper-3.4.5
└── server005
├── data
├── logs
└── zookeeper-3.4.5
這樣就配置好了,windows下的單機偽集群。
下面就是啟動了:
進入bin下
雙擊 :zkserver.cmd
報這個錯誤是因為還有節點沒有啟動起來,都啟動了就會不報錯了
執行 zkserver.cmd status 可以檢視節點的角色 是leader 還是follower
這樣乙個偽集群就成功了,如果有不對的地方希望大家批評指正,orz。
zookeeper集群搭建
接觸zookeeper集群已有很長很長一段時間了,zookeeper在專案中的使用相當的頻繁,如dubb服務 amq集群 大資料領域hadoop等。zookeeper的集群建立非常簡單,一直想寫一篇文章來對集群使用的介紹,但一直沒能抽出空,今天正好閒來無事,就重新實踐一遍來整理記錄,下文是基本的集群...
zookeeper集群搭建
zookeeper環境搭建需要保證奇數臺機器,以保證演算法能選舉出乙個leader。一 環境準備 datadir dir ticktime 2000 initlimit 5 synclimit 2 clientport 2181 server.0 192.168.1.100 2888 3888 se...
zookeeper集群搭建
1.準備工作 tomcat zookeeper 最少三個結點搭乙個集群,所以複製三份 2.搭建並配置三個zookeeper例項 cd usr local solr cloud zookeeper01 進zookeeper01目錄,mkdir data 該目錄下建立data資料夾,放置zookeepe...