01_hadoop集群启停脚本&批量检查集群服务

[root@hadoop01 software]# cat myhadoop.sh 
#!/bin/bash
#检查脚本参数个数
if [ $# -lt 1 ]
then
    echo "No Args Input... please input [start|stop]"
fi

case $1 in 
"start")
        echo " ============================= 启动 hadoop 集群 ================================="
        
        echo " ----------------------------- 启动 hdfs ----------------------------------------"
        ssh hadoop01 "/home/software/hadoop-3.1.3/sbin/start-dfs.sh"
        echo " ----------------------------- 启动 yarn -----------------------------------------"
        ssh hadoop02 "/home/software/hadoop-3.1.3/sbin/start-yarn.sh"
        echo " ----------------------------- 启动 historyserver --------------------------------"
        ;;
"stop")
        echo " ============================= 关闭 hadoop 集群 ================================="

        echo " ----------------------------- 关闭 historyserver --------------------------------"
  
        echo " ----------------------------- 关闭 yarn -----------------------------------------"
        ssh hadoop02 "/home/software/hadoop-3.1.3/sbin/stop-yarn.sh"
        echo " ----------------------------- 关闭 hdfs ----------------------------------------"
        ssh hadoop01 "/home/software/hadoop-3.1.3/sbin/stop-dfs.sh"
        ;;
*)
        echo "Input Args Error... please input [start|stop]"
;;
esac

-- 批量检查集群服务

[root@hadoop01 software]# cat jpsall
#!/bin/bash

for host in hadoop01 hadoop02 hadoop03
do
        echo "=============== $host ====================="
        ssh $host jps
done

 

上一篇:12-MyBatis逆向生成工具


下一篇:ESXI6.0开启网页控制UI