安装zookeeper
tar -zxvf 源路径 -C 目标路径
找到zookeeper/conf下对zoo_sample.cfg改名(ps:因为系统不会认)

对zoo.cfg进行配置
修改vi /etc/profile.d/my_env.sh
添加环境变量
bash
[hadoop@hadoop01 ~]$ cat /etc/profile.d/my_env.sh
#JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_212
export PATH=$PATH:$JAVA_HOME/bin
#HADOOP_HOME
export HADOOP_HOME=/opt/module/hadoop-3.3.4
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
#ZK_HOME
export ZK_HOME=/opt/module/zookeeper
export PATH=$PATH:$ZK_HOME/bin
修改zoo.cfg(数据存储目录和集群节点和服务器端口配置)
然后分发
修改myid内容(1 2 3)
脚本
1)在hadoop102的/home/wyr/bin目录下创建脚本
wyr@hadoop102 bin\]$ vim zk.sh 在脚本中编写如下内容 #!/bin/bash if \[ $# -lt 1
then
echo "No Args Input...(启动Zookeeper集群:zk.sh start;停止Zookeeper集群:zk.sh stop;Zookeeper集群状态:zk.sh status)"
exit ;
fi
case $1 in
"start"){
for i in hadoop102 hadoop103 hadoop104
do
echo ---------- zookeeper $i 启动 ------------
ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh start"
done
};;
"stop"){
for i in hadoop102 hadoop103 hadoop104
do
echo ---------- zookeeper $i 停止 ------------
ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh stop"
done
};;
"status"){
for i in hadoop102 hadoop103 hadoop104
do
echo ---------- zookeeper $i 状态 ------------
ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh status"
done
};;
esac
2)增加脚本执行权限
wyr@hadoop102 bin\]$ chmod +x zk.sh