#! /bin/bash
# 开启zookeeper集群
function zookeeper_start(){
echo "========zookeeper集群启动中...========";
echo "--------pc001 zookeeper服务启动--------";
ssh pc001 "zkServer.sh start";
echo "--------pc002 zookeeper服务启动--------"
ssh pc002 "zkServer.sh start";
echo "--------pc003 zookeeper服务启动--------"
ssh pc003 "zkServer.sh start";
}
# 关闭zookeeper集群
function zookeeper_stop(){
echo "========zookeeper集群关闭中...========";
echo "--------pc001 zookeeper服务关闭--------";
ssh pc001 "zkServer.sh stop";
echo "--------pc002 zookeeper服务关闭--------"
ssh pc002 "zkServer.sh stop";
echo "--------pc003 zookeeper服务关闭--------"
ssh pc003 "zkServer.sh stop";
}
# 查看集群状态
function zookeeper_status(){
echo "========zookeeper集群状态========";
echo "--------pc001 zookeeper服务状态--------";
ssh pc001 "zkServer.sh status";
echo "--------pc002 zookeeper服务状态--------";
ssh pc002 "zkServer.sh status";
echo "--------pc003 zookeeper服务状态--------";
ssh pc003 "zkServer.sh status";
}
case $1 in
"start")
zookeeper_start;
;;
"stop")
zookeeper_stop;
;;
"status")
zookeeper_status;
;;
"restart")
zookeeper_stop;
zookeeper_start;
;;
*)
echo "Invalid Args!";
echo "Usage: xzookeeper.sh start|stop|restart|status";
;;