#!/bin/bash
if [ $# -lt 1 ]
then
echo "No Args Input..."
exit ;
fi
user=`whoami`
hadoop_home=/opt/module/hadoop-3.1.3
case $1 in
"start")
echo " =================== 启动 hadoop 集群 ==================="
echo " --------------- 启动 hdfs ---------------"
ssh $user@hadoop102 "$hadoop_home/sbin/start-dfs.sh"
echo " --------------- 启动 yarn ---------------"
ssh $user@hadoop103 "$hadoop_home/sbin/start-yarn.sh"
echo " --------------- 启动 historyserver ---------------"
ssh $user@hadoop102 "$hadoop_home/bin/mapred --daemon start historyserver"
;;
"stop")
echo " =================== 关闭 hadoop 集群 ==================="
echo " --------------- 关闭 historyserver ---------------"
ssh $user@hadoop102 "$hadoop_home/bin/mapred --daemon stop historyserver"
echo " --------------- 关闭 yarn ---------------"
ssh $user@hadoop103 "$hadoop_home/sbin/stop-yarn.sh"
echo " --------------- 关闭 hdfs ---------------"
ssh $user@hadoop102 "$hadoop_home/sbin/stop-dfs.sh"
;;
*)
echo "Input Args Error..."
;;
esac
12-14
563
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-03
4036
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)