[alex@hadoop102 ~]$ touch ~/bin/zk.sh
[alex@hadoop102 ~]$ chmod 755 ~/bin/zk.sh
[alex@hadoop102 ~]$ vim ~/bin/zk.sh
#!/bin/bash
user=`whoami`
zookeeper_home=/opt/module/zookeeper-3.5.7
echo -e "================ 正在启动Zookeeper ===========\n"
case $1 in
start | stop | status)
for((host=102; host<=104; host++)); do
echo -e "\n---${user}@hadoop${host}---"
ssh ${user}@hadoop${host} "${zookeeper_home}/bin/zkServer.sh $1"
done
;;
*)
echo "你启动的姿势不对"
echo " start 启动zookeeper集群"
echo " stop 停止zookeeper集群"
echo " status 查看zookeeper集群"
;;
esac
[alex@hadoop102 ~]$ zk.sh status
10-28
947
03-29
3017
03-12
3458