Zookeeper 群起脚本配置

昨天刚做完 hadoop 高可用配置,里面的3台centos均安装了 Zookeeper,但是启动要一台台启动太麻烦了,这里抽空写一个Zookeeper的群起脚本,方便快速启动3台服务器的Zookeeper服务。

mkdir -p /home/hadoop/bin vim /home/hadoop/bin/my_zk.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash

#检验参数
if [ $# -lt 1 ]
then
echo '参数不能为空!!!'
exit
fi

#循环遍历每一台机器,分别启动或者停止ZK服务

for host in hadoop112 hadoop113 hadoop114
do
case $1 in
"start")
echo "*****************start $host zookeeper****************"
ssh $host /devops/apache-zookeeper-3.5.7-bin/bin/zkServer.sh $1
;;

"stop")
echo "*****************stop $host zookeeper****************"
ssh $host /devops/apache-zookeeper-3.5.7-bin/bin/zkServer.sh $1
;;

"status")
echo "*****************status $host zookeeper****************"
ssh $host /devops/apache-zookeeper-3.5.7-bin/bin/zkServer.sh $1
;;

*)
echo '参数有误!!!'
exit
;;
esac
done

chmod 744 my_zk.sh

Alt text

Alt text

搞定

|