zk.sh
#!/bin/bash
if [ $# -lt 1 ]
then
echo "Please type parameter like <start> or <stop> or <status>"
exit ;
fi
case $1 in
"start")
echo " ================= 1-启动 Zookeeper集群 ================="
for host in hadoop101 hadoop102 hadoop103
do
echo " ----------- On server: $host ------------"
ssh $host "source /etc/profile && /opt/module/zookeeper-3.5.7/bin/zkServer.sh start"
done
;;
"stop")
echo " ================= 2-关闭 Zookeeper集群 ================="
for host in hadoop101 hadoop102 hadoop103
do
echo " ----------- On server: $host ------------"
ssh $host "source /etc/profile && /opt/module/zookeeper-3.5.7/bin/zkServer.sh stop"
done
;;
"status")
echo " ================= 3-查看 Zookeeper集群 状态================="
for host in hadoop101 hadoop102 hadoop103
do
echo " ----------- On server: $host ------------"
ssh $host "source /etc/profile && /opt/module/zookeeper-3.5.7/bin/zkServer.sh status"
done
;;
*)
echo "Input parameter Error, please have a check!"
;;
esac