注意:需要依赖jdk
三台服务器分别是
192.168.0.101
192.168.0.102
192.168.0.103
然后在三台服务器分别安装zookeeper
下载
wget https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz
解压到user/local下
mv /usr/local/soft/apache-zookeeper-3.7.0 /usr/local/soft/zookeeper
修改配置文件
vim /usr/local/zookeeper/conf/zoo.cfg
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/soft/data
clientPort=2181
server.1=192.168.0.101:2888:3888
server.2=192.168.0.102:2888:3888
server.3=192.168.0.103:2888:3888
创建数据存储目录
mkdir -p /usr/local/soft/zookeeper/data
192.168.0.102和192.168.0.103机器上拷贝zookeeper目录
scp -r root@192.168.0.101:/usr/local/soft/zookeeper /usr/local/soft/
然后分别在3台机器上进行如下操作
创建myid文件, id 与 zoo.cfg 中的序号对应
#在192.168.0.101机器上执行
echo 1 > /usr/local/soft/zookeeper/data/myid
#在192.168.2.102机器上执行
echo 2 > /usr/local/soft/zookeeper/data/myid
#在192.168.2.103机器上执行
echo 3 > /usr/local/soft/zookeeper/data/myid
配置环境变量
vim /etc/profile
在最后加上
export ZK_HOME=/usr/local/soft/zookeeper
export PATH=$ZK_HOME/bin:$PATH
强制生效
source /etc/profile
分别启动
zkServer.sh start
查看状态
zkServer.sh status
参考博客:https://gper.club/articles/7e7e7f7ff4g5dgc6g64