玩大数据的小伙伴应该知道,大数据生态圈框架越来越多,开机关机相当费劲,今天楼主给大家整理了常用的一些脚本,办公学习都可用,赶紧来看看吧!!
1.检查集群当前进程脚本:
for host in hadoop102 hadoop103 hadoop104
do
echo ===============
$host ===============
ssh
$host jps $@
| grep
-v Jps
done
2.Hadoop集群群起,群停脚本: 这里以3台机器为例
if [ $
then
echo "No Args Input..."
exit ;
fi
case
$1 in
"start")
echo " =================== 启动 hadoop集群 ==================="
echo " --------------- 启动 hdfs ---------------"
ssh hadoop102
"/opt/module/hadoop-3.1.3/sbin/start-dfs.sh"
echo " --------------- 启动 yarn ---------------"
ssh hadoop103
"/opt/module/hadoop-3.1.3/sbin/start-yarn.sh"
echo " --------------- 启动 historyserver ---------------"
ssh hadoop102
"/opt/module/hadoop-3.1.3/bin/mapred --daemon start historyserver"
;;
"stop")
echo " =================== 关闭 hadoop集群 ==================="
echo " --------------- 关闭 historyserver ---------------"
ssh hadoop102
"/opt/module/hadoop-3.1.3/bin/mapred --daemon stop historyserver"
echo " --------------- 关闭 yarn ---------------"
ssh hadoop103
"/opt/module/hadoop-3.1.3/sbin/stop-yarn.sh"
echo " --------------- 关闭 hdfs ---------------"
ssh hadoop102
"/opt/module/hadoop-3.1.3/sbin/stop-dfs.sh"
;;
*)
echo "Input Args Error..."
;;
esac
3.各机器之间文件同步脚本:
if [ $
then
echo Not Enough Arguement
!
exit;
fi
for host in hadoop102 hadoop103 hadoop104
do
echo ====================
$host ====================
for file in $@
do
if [ -e
$file ]
then
pdir=$
(cd
-P $
(dirname
$file); pwd)
fname=$
(basename
$file)
ssh
$host "mkdir -p $pdir"
rsync
-av
$pdir/$fname $host:
$pdir
else
echo $file does not exists
!
fi
done
done
4.zookeeper群起,群停脚本,3台机器为例:
if [ $
then
echo "No Args Input..."
exit ;
fi
case
$1 in
"start")
for i in hadoop102 hadoop103 hadoop104
do
echo "===================== $i ======================="
ssh
$i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh start"
done
;;
"stop")
for i in hadoop102 hadoop103 hadoop104
do
echo "===================== $i ======================="
ssh
$i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh stop"
done
;;
"status")
for i in hadoop102 hadoop103 hadoop104
do
echo "===================== $i ======================="
ssh
$i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh status"
done
;;
*)
echo "Input Args Error..."
;;
esac
5.kafka群起,群停脚本:
if [ $
then
echo "Input Args Error....."
exit
fi
for i in hadoop102 hadoop103 hadoop104
do
case
$1 in
start)
echo "==================START $i KAFKA==================="
ssh
$i /opt
/module
/kafka_2
.11
-2
.4
.1
/bin
/kafka
-server
-start.sh
-daemon
/opt
/module
/kafka_2
.11
-2
.4
.1
/config
/server
.properties
;;
stop
)
echo "==================STOP $i KAFKA==================="
ssh
$i /opt
/module
/kafka_2
.11
-2
.4
.1
/bin
/kafka
-server
-stop
.sh stop
;;
*)
echo "Input Args Error....."
exit
;;
esac
done
觉得有用的小伙伴可以的收藏和关注哦 后面整理完持续更新。。。。