1、解压、配置环境变量
cd /opt/software
tar -xvf apache-zookeeper-3.5.7-bin.tar.gz
mv apache-zookeeper-3.5.7-bin ../module/zookeeper-3.5.7
mkdir /opt/module/zookeeper-3.5.7/zkData
vim /etc/profile
#Zookeeper
export ZK_HOME=/opt/module/zookeeper-3.5.7
export PATH=$PATH:$ZK_HOME/bin
source /etc/profile
mkdir $ZK_HOME/zkData
echo 0 > $ZK_HOME/zkData/myid
echo 1 > $ZK_HOME/zkData/myid
echo 2 > $ZK_HOME/zkData/myid
2、配置 zoo.cfg
cp $ZK_HOME/conf/zoo_sample.cfg $ZK_HOME/conf/zoo.cfg
vim $ZK_HOME/conf/zoo.cfg
dataDir=/opt/module/zookeeper-3.5.7/zkData
server.0=master:2888:3888
server.1=slave1:2888:3888
server.2=slave2:2888:3888
# 分发
scp $ZK_HOME/conf/zoo.cfg slave1:$ZK_HOME/conf/
scp $ZK_HOME/conf/zoo.cfg slave2:$ZK_HOME/conf/
3、启动集群
# 结束 $ZK_HOME/bin/zkServer.sh stop
$ZK_HOME/bin/zkServer.sh start
评论