「Apache ZooKeeper」:修訂間差異

出自Gea-Suan Lin's Wiki
跳至導覽 跳至搜尋
本頁面具有訪問限制。如果您看見此訊息,這代表您沒有訪問本頁面的權限。
 
(未顯示同一使用者於中間所作的 20 次修訂)
行 1: 行 1:
'''ZooKeeper'''是一套分散 式的Key-Value系統。
'''ZooKeeper'''是一套 基於[[Java]]的 分散 式Key-Value系統
 
== 硬體 ==
 
在測試環境下,ZooKeeper可以只使用<code>t3.nano</code>(512 MB的記憶體),另外手動加上512 MB的Swap執行。
 
在正式環境下,[[Confluent]]官方的建議是4 GB的記憶體與64 GB以上的SSD<ref>{{Cite web |url=https://docs.confluent.io/platform/current/zookeeper/deployment.html |title=Running ZooKeeper in Production |language=en |accessdate=2021-05-18}}</ref>


== 安裝 ==
== 安裝 ==


[[Ubuntu]] 18.04所內附的ZooKeeper 已經夠新,可以直接 安裝 使用
[[Ubuntu]] 的系統內有提供ZooKeeper套件,另外在[[Confluent]]的套件中也有提供(通常會在配合[[Apache Kafka]]時使用)。
 
這邊會使用Ubuntu 18.04所內附的ZooKeeper安裝:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
行 9: 行 17:
</syntaxhighlight>
</syntaxhighlight>


 其中<code>zookeeperd</code>是開機時的script。
 其中<code>zookeeper</code>是程式本體,而<code>zookeeperd</code>是開機時 跑起 的script。


== 設定 ==
== 設定 ==
先把<code>/etc/zookeeper/conf_example/</code>的內容複製一份到<code>/etc/zookeeper/conf_production/</code>下:
<syntaxhighlight lang="bash">
sudo cp -R /etc/zookeeper/conf_example/ /etc/zookeeper/conf_production/
</syntaxhighlight>


 每台機器的<code>/etc/zookeeper/conf_production/myid</code>都需要不同,可以從<code>1</code>到<code>255</code>:
 每台機器的<code>/etc/zookeeper/conf_production/myid</code>都需要不同,可以從<code>1</code>到<code>255</code>:
行 32: 行 46:
</syntaxhighlight>
</syntaxhighlight>


  修改 設定檔 目錄:
  告訴系統應該要讀哪個 設定檔 目錄


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
行 39: 行 53:
</syntaxhighlight>
</syntaxhighlight>


 然後 連結
 然後 設定在開機時啟動


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo systemctl daemon-reload
sudo systemctl enable zookeeper
sudo systemctl enable zookeeper
</syntaxhighlight>
</syntaxhighlight>
行 53: 行 66:


== 測試 ==
== 測試 ==
可以看輸出的資訊判斷:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
echo stat | nc 127.0.0.1 2181
echo stat | nc 127.0.0.1 2181
</syntaxhighlight>
</syntaxhighlight>
== 相關連結 ==
* [[Apache Kafka]]
* [[Confluent]]
* [[Confluent/ZooKeeper]]
== 參考文獻 ==
{{Reflist|2}}


== 外部連結 ==
== 外部連結 ==

於 2021年5月18日 (二) 14:38 的最新修訂

ZooKeeper是一套基於Java的分散式Key-Value系統。

硬體

在測試環境下,ZooKeeper可以只使用t3.nano(512 MB的記憶體),另外手動加上512 MB的Swap執行。

在正式環境下,Confluent官方的建議是4 GB的記憶體與64 GB以上的SSD[1]

安裝

Ubuntu的系統內有提供ZooKeeper套件,另外在Confluent的套件中也有提供(通常會在配合Apache Kafka時使用)。

這邊會使用Ubuntu 18.04所內附的ZooKeeper安裝:

sudo apt install -y zookeeper zookeeperd

其中zookeeper是程式本體,而zookeeperd是開機時跑起的script。

設定

先把/etc/zookeeper/conf_example/的內容複製一份到/etc/zookeeper/conf_production/下:

sudo cp -R /etc/zookeeper/conf_example/ /etc/zookeeper/conf_production/

每台機器的/etc/zookeeper/conf_production/myid都需要不同,可以從1255

1

這邊要列出所有機器/etc/zookeeper/conf_production/zoo.cfg

tickTime=2000
dataDir=/var/lib/zookeeper/
clientPort=2181
initLimit=5
syncLimit=2
server.1=172.31.x:2888:3888
server.2=172.31.x:2888:3888
server.3=172.31.x:2888:3888

告訴系統應該要讀哪個設定檔(目錄):

sudo update-alternatives --install /etc/zookeeper/conf zookeeper-conf /etc/zookeeper/conf_production 1
sudo update-alternatives --set zookeeper-conf /etc/zookeeper/conf_production

然後設定在開機時啟動:

sudo systemctl enable zookeeper

可以重開機,或是直接跑起來:

sudo service zookeeper start

測試

可以看輸出的資訊判斷:

echo stat | nc 127.0.0.1 2181

相關連結

參考文獻

  1. Running ZooKeeper in Production. [2021-05-18] (English). 

外部連結