使用myhadoop.sh脚本时出错:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/341014baa99dc5f1c681c5a015061922.png)
解决方案:
- 删掉haoop安装目录下 /opt/module/hadoop-3.3.0/etc/hadoop/workers 文件里面的localhost
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ab7e9e7fc923b49fd051c6c5edbde8fd.png)
- 保存后可成功运行脚本
附上:myhadoop.sh(实现hadoop集群快速启停)
#!/bin/bash
if [ $# -lt 1 ]
then
echo "No Args Input..."
exit ;
fi
case $1 in
"start")
echo " =================== 启动 hadoop 集群 ==================="
echo " --------------- 启动 hdfs ---------------"
ssh hadoop102 "/opt/module/hadoop-3.3.0/sbin/start-dfs.sh"
echo " --------------- 启动 yarn ---------------"
ssh hadoop103 "/opt/module/hadoop-3.3.0/sbin/start-yarn.sh"
echo " --------------- 启动 historyserver ---------------"
ssh hadoop102 "/opt/module/hadoop-3.3.0/bin/mapred --daemon start
historyserver"
;;
"stop")
echo " =================== 关闭 hadoop 集群 ==================="
echo " --------------- 关闭 historyserver ---------------"
ssh hadoop102 "/opt/module/hadoop-3.3.0/bin/mapred --daemon stop
historyserver"
echo " --------------- 关闭 yarn ---------------"
ssh hadoop103 "/opt/module/hadoop-3.3.0/sbin/stop-yarn.sh"
echo " --------------- 关闭 hdfs ---------------"
ssh hadoop102 "/opt/module/hadoop-3.3.0/sbin/stop-dfs.sh"
;;
*)
echo "Input Args Error..."
;;
esac