Hadoop 一些脚本总结

1.各个模板分开启动/停止

1.整体启动/停止 HDFS

start-dfs.sh / stop-dfs.sh

2.整体启动/停止 YARN

start-yarn.sh / stop-yarn.sh

2.各个服务组件逐一启动/停止

1.分别启动/停止 HDFS组件

hdfs --daemon start/stop namenode/datanode/secondarynamenode

2.分别启动/停止 YARN组件

yarn --daemon start/stop resourcemanager/nodemanager

3.集群自定义脚本

1.集群启动/停止脚本

#!/bin/bash

if [ $# -lt 1 ]
then
	echo "No Args Input..."
	exit;
fi

case $1 in
"start")
	echo " ==================启动Hadoop集群 ================== "
	
	echo " ------------------ 启动 hdfs ------------------ "
	ssh 192.168.58.130 "/usr/hadoop/hadoop-3.3.6/sbin/start-dfs.sh"
	echo " ------------------ 启动 yarn ------------------ "
	ssh 192.168.58.131 "/usr/hadoop/hadoop-3.3.6/sbin/start-yarn.sh"
	echo " ------------------ 启动 historyServer ------------------ "
	ssh 192.168.58.131 "/usr/hadoop/hadoop-3.3.6/bin/mapred --daemon start historyserver"
;;
"stop")
	echo " ================== 关闭hadoop集群 ================== "

	echo " ------------------ 关闭historyServer ------------------ "
	ssh 192.168.58.131 "/usr/hadoop/hadoop-3.3.6/bin/mapred --daemon stop historyserver"
	echo " ------------------ 关闭 yarn ------------------ "
	ssh 192.168.58.131 "/usr/hadoop/hadoop-3.3.6/sbin/stop-yarn.sh"
	echo " ------------------ 关闭 hdfs ------------------ "
	ssh 192.168.58.130 "/usr/hadoop/hadoop-3.3.6/sbin/stop-dfs.sh"
;;
*)
	echo "Input Args Error..."
;;
esac
chmod +x shellFileName.sh

2.查看集群Java进程脚本

#!/bin/bash

for host in 192.168.58.130 192.168.58.131 192.168.58.132
do
	echo ========================= $host =========================
	ssh $host "source /etc/profile;jps $@ | grep -v Jps"
done
chmod +x shellFileName.sh
posted @ 2023-12-01 19:04  SpringCore  阅读(18)  评论(0编辑  收藏  举报