黑猴子的家:zk.sh

在/usr/local/bin 目录下

[alex@hadoop102 ~]$ cd /usr/local/bin/
[alex@hadoop102 bin]$ sudo touch zk.sh
[alex@hadoop102 bin]$ sudo chown alex:alex zk.sh
[alex@hadoop102 bin]$ chmod 755 zk.sh
[alex@hadoop102 bin]$ vim zk.sh
#!/bin/bash

user=`whoami`

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 "/opt/module/zookeeper-3.4.10/bin/zkServer.sh $1"
        done
    ;;
    *)
        echo "你启动的姿势不对"
        echo "  start   启动zookeeper集群"
        echo "  stop    停止zookeeper集群"
        echo "  status  查看zookeeper集群"
    ;;
esac

你可能感兴趣的:(黑猴子的家:zk.sh)