「Apache ZooKeeper」:修訂間差異

出自Gea-Suan Lin's Wiki
跳至導覽 跳至搜尋
本頁面具有訪問限制。如果您看見此訊息,這代表您沒有訪問本頁面的權限。
行 12: 行 12:


 每台機器的<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>:
<syntaxhighlight lang="ini">
<syntaxhighlight lang="ini">
1
1
行 17: 行 18:


 這邊要列出所有機器<code>/etc/zookeeper/conf_production/zoo.cfg</code>:
 這邊要列出所有機器<code>/etc/zookeeper/conf_production/zoo.cfg</code>:
<syntaxhighlight lang="ini">
<syntaxhighlight lang="ini">
tickTime=2000
tickTime=2000
行 29: 行 31:


 接下來是設定systemd的<code>/lib/systemd/system/zookeeper.service</code>:
 接下來是設定systemd的<code>/lib/systemd/system/zookeeper.service</code>:
<syntaxhighlight lang="ini">
<syntaxhighlight lang="ini">
[Unit]
[Unit]
行 40: 行 43:
User=nobody
User=nobody
Group=nogroup
Group=nogroup
ExecStart=/usr/share/zookeeper/bin/zkServer.sh start /etc/zookeeper/conf/zookeeper.conf
ExecStart=/usr/share/zookeeper/bin/zkServer.sh start /etc/zookeeper/conf/zoo.conf
ExecStop=/usr/share/zookeeper/bin/zkServer.sh stop /etc/zookeeper/conf/zookeeper.conf
ExecStop=/usr/share/zookeeper/bin/zkServer.sh stop /etc/zookeeper/conf/zoo.conf
ExecReload=/usr/share/zookeeper/bin/zkServer.sh restart /etc/zookeeper/conf/zookeeper.conf
ExecReload=/usr/share/zookeeper/bin/zkServer.sh restart /etc/zookeeper/conf/zoo.conf
WorkingDirectory=/var/lib/zookeeper
WorkingDirectory=/var/lib/zookeeper


[Install]
[Install]
WantedBy=default.target
WantedBy=default.target
</syntaxhighlight>
修改設定檔的目錄:
<syntaxhighlight lang="bash">
sudo update-alternatives --install /etc/zookeeper/conf zookeeper-conf /etc/zookeeper/conf_production 1
sudo update-alternatives --set zookeeper-conf /etc/zookeeper/conf_production
</syntaxhighlight>
</syntaxhighlight>



於 2019年2月28日 (四) 04:28 的修訂

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

安裝

Ubuntu下可以直接安裝:

sudo apt install -y zookeeper

設定

每台機器的/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

接下來是設定systemd的/lib/systemd/system/zookeeper.service

[Unit]
Description=ZooKeeper Service
Documentation=http://zookeeper.apache.org
Requires=network.target
After=network.target

[Service]
Type=forking
User=nobody
Group=nogroup
ExecStart=/usr/share/zookeeper/bin/zkServer.sh start /etc/zookeeper/conf/zoo.conf
ExecStop=/usr/share/zookeeper/bin/zkServer.sh stop /etc/zookeeper/conf/zoo.conf
ExecReload=/usr/share/zookeeper/bin/zkServer.sh restart /etc/zookeeper/conf/zoo.conf
WorkingDirectory=/var/lib/zookeeper

[Install]
WantedBy=default.target

修改設定檔的目錄:

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 daemon-reload
sudo systemctl enable zookeeper

外部連結