1 官网下载Index of /dist/zookeeper
下载版本3.5.7
2 将安装文件复制到服务器,并解压
tar -zxvf /tmp/zookeeper.tar.gz -C /opt/module
mv zookeeper.3.5.7-bin zookeeper-3.5.7
3 在zookeeper目录下新建zkData目录
4 修改配置文件名,改为zoo.cfg ,修改配置文件内容
vim conf/zoo.cfg
dataDir=/opt/module/zookeeper-3.5.7/zkData
server.2=hadoop102:2888:3888
server.3=hadoop103:2888:3888
server.4=hadoop104:2888:3888
5 xsync分发
6 在zkData下新建myid文件,内容为不重复的数字
hadoop102下为2
hadoop103下为3
hadoop104下为4
7 编写集群启动 停止脚本
在/home/yang/bin下创建zk.sh
#!/bin/bash
case $1 in
"start"){
for i in hadoop102 hadoop103 hadoop104
do
echo "--------------------zookeeper $i starting----------------------"
ssh -p 1774 $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh start"
done
}
;;
"stop"){
for i in hadoop102 hadoop103 hadoop104
do
echo "--------------------zookeeper $i stopping----------------------"
ssh -p 1774 $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh stop"
done
}
;;
"status"){
for i in hadoop102 hadoop103 hadoop104
do
echo "--------------------zookeeper $i status----------------------"
ssh -p 1774 $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh status"
done
}
;;
esac
8 分别执行命令是否成功
zk.sh start
zk.sh status
zk.sh stop