日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

zookeeper集群搭建设置

發布時間:2025/4/16 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 zookeeper集群搭建设置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

zookeeper 官網:http://zookeeper.apache.org/?現在最新版本是 3.4.6 ,但是這個版本我沒有運行起來,可能是那配置出現問題了,現在我用的是3.4.5?http://apache.fayea.com/apache-mirror/zookeeper/zookeeper-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. # #?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

    ? ? ? 修改后:

    #?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. # #?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=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地址,因為我的都是本機,所以我這都是一樣的地址。

    ? 參數解釋:

    • tickTime:發送心跳的間隔時間,單位:毫秒

    • dataDir:zookeeper保存數據的目錄。

    • clientPort:客戶端連接 Zookeeper 服務器的端口,Zookeeper 會監聽這個端口,接受客戶端的訪問請求。

    • initLimit:這個配置項是用來配置 Zookeeper 接受客戶端(這里所說的客戶端不是用戶連接 Zookeeper 服務器的客戶端,而是 Zookeeper 服務器集群中連接到 Leader 的 Follower 服務器)初始化連接時最長能忍受多少個心跳時間間隔數。當已經超過 5個心跳的時間(也就是 tickTime)長度后 Zookeeper 服務器還沒有收到客戶端的返回信息,那么表明這個客戶端連接失敗??偟臅r間長度就是 5*2000=10 秒

    • syncLimit:這個配置項標識 Leader 與 Follower 之間發送消息,請求和應答時間長度,最長不能超過多少個 tickTime 的時間長度,總的時間長度就是 2*2000=4 秒

    • server.A=B:C:D:其中 A 是一個數字,表示這個是第幾號服務器;B 是這個服務器的 ip 地址;C 表示的是這個服務器與集群中的 Leader 服務器交換信息的端口;D 表示的是萬一集群中的 Leader 服務器掛了,需要一個端口來重新進行選舉,選出一個新的 Leader,而這個端口就是用來執行選舉時服務器相互通信的端口。如果是偽集群的配置方式,由于 B 都是一樣,所以不同的 Zookeeper 實例通信端口號不能一樣,所以要給它們分配不同的端口號。

    ? 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。

    參考文章:

    http://www.cnblogs.com/haippy/archive/2012/07/19/2599989.html

    http://zookeeper.apache.org/

    http://zookeeper.apache.org/doc/current/zookeeperStarted.html

    http://zookeeper.apache.org/doc/current/index.html

    http://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/

    轉載于:https://www.cnblogs.com/duyinqiang/p/5696326.html

    總結

    以上是生活随笔為你收集整理的zookeeper集群搭建设置的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。