具体代码
#!/bin/bash
if [ $# -lt 1 ]
then
echo "No Args Input..."
exit ;
fi
case $1 in
"start")
echo " =================== 启动 hadoop集群 ==================="
echo ""
echo " --------------- 启动 hdfs ---------------"
ssh hadoop11 "/opt/module/hadoop-3.1.3/sbin/start-dfs.sh"
echo ""
echo " --------------- 启动 yarn ---------------"
ssh hadoop12 "/opt/module/hadoop-3.1.3/sbin/start-yarn.sh"
echo ""
echo " ------------- 启动 历史服务器 -----------"
ssh hadoop11 "mapred --daemon start historyserver"
# 添加Web访问地址
echo ""
echo ""
echo "======Hadoop Web UI 访问地址========"
echo "HDFS:http://hadoop11:9870"
echo "YARN 资源管理器:http://hadoop12:8088"
echo "MapReduce历史服务器:http://hadoop11:19888/jobhistory"
echo "====================================="
;;
"stop")
echo " =================== 关闭 hadoop集群 ==================="
echo ""
echo " --------------- 关闭 yarn ---------------"
ssh hadoop12 "/opt/module/hadoop-3.1.3/sbin/stop-yarn.sh"
echo ""
echo " --------------- 关闭 hdfs ---------------"
ssh hadoop11 "/opt/module/hadoop-3.1.3/sbin/stop-dfs.sh"
echo ""
echo " ------------- 关闭 历史服务器 -----------"
ssh hadoop11 "mapred --daemon stop historyserver"
;;
*)
echo "输入参数有误..."
;;
esac