1.环境和版本
服务器:centos
zookeeper版本号:zookeeper-3.4.14
- zookeeper使用端口号
节点 | 端口 |
---|---|
z1 | 2181 |
z2 | 2182 |
z3 | 2183 |
- 备注:外网连接需更改firewall防火墙配置
firewall-cmd --permanent --zone=public --add-port=2181/tcp
systemctl restart firewalld
2.步骤
2.1安装zookeeper和相关软件
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 #其它节点修改
clientPort=2181 #其它节点修改
dataLogDir=/usr/local/zookeeper/zk/logs #其它节点修改
server.1=localhost:2287:3387
server.2=localhost:2288:3388
server.3=localhost:2289:3389
其它节点配置同上
#添加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
#查看状态
./zkServer.sh status ../conf/zoo2.cfg
网友评论