Apache ZooKeeper:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
第70行: 第70行:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo service zookeeper start
sudo service zookeeper start
</syntaxhighlight>
== 測試 ==
<syntaxhighlight lang="bash">
echo srvr | nc 127.0.0.1 2181
echo stat | nc 127.0.0.1 2181
</syntaxhighlight>
</syntaxhighlight>



2019年2月28日 (四) 04:45的版本

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=https://zookeeper.apache.org
Requires=network.target
After=network.target

[Service]
Type=forking
User=zookeeper
Group=zookeeper
ExecStart=/usr/share/zookeeper/bin/zkServer.sh start /etc/zookeeper/conf/zoo.cfg
ExecStop=/usr/share/zookeeper/bin/zkServer.sh stop /etc/zookeeper/conf/zoo.cfg
ExecReload=/usr/share/zookeeper/bin/zkServer.sh restart /etc/zookeeper/conf/zoo.cfg
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

可以重开机,或是直接跑起来:

sudo service zookeeper start

测试

echo srvr | nc 127.0.0.1 2181
echo stat | nc 127.0.0.1 2181

外部连结