1.環(huán)境和版本
服務(wù)器:centos
zookeeper版本號:zookeeper-3.4.14
- zookeeper使用端口號
節(jié)點 | 端口 |
---|---|
z1 | 2181 |
z2 | 2182 |
z3 | 2183 |
- 備注:外網(wǎng)連接需更改firewall防火墻配置
firewall-cmd --permanent --zone=public --add-port=2181/tcp
systemctl restart firewalld
2.步驟
2.1安裝zookeeper和相關(guān)軟件
wget http://mirror.bit.edu.cn/apache/zookeeper/stable/zookeeper-3.4.14.tar.gz
tar -zxvf zookeeper-3.4.14.tar.gz -c zookeeper
cd zookeeper
mkdir conf
touch conf/{zoo.cfg,zoo2.cfg,zoo3.cfg}
mkdir -p /usr/local/zookeeper/{zk,zk2,zk3}/{data,logs}
2.2配置
vim conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/zk/data #其它節(jié)點修改
clientPort=2181 #其它節(jié)點修改
dataLogDir=/usr/local/zookeeper/zk/logs #其它節(jié)點修改
server.1=localhost:2287:3387
server.2=localhost:2288:3388
server.3=localhost:2289:3389
其它節(jié)點配置同上
#添加myid
echo 1 > /usr/local/zookeeper/zk/data/myid
echo 2 > /usr/local/zookeeper/zk2/data/myid
echo 3 > /usr/local/zookeeper/zk3/data/myid
#啟動
cd bin
./zkServer.sh start
./zkServer.sh start ../conf/zoo2.cfg
./zkServer.sh start ../conf/zoo3.cfg
#查看狀態(tài)
./zkServer.sh status ../conf/zoo2.cfg