大数据生态圈各个框架常用脚本大全,学习办公通用,妈妈再也不用担心老板让我写脚本了,收藏走起!!!

tech2024-01-09  80

玩大数据的小伙伴应该知道,大数据生态圈框架越来越多,开机关机相当费劲,今天楼主给大家整理了常用的一些脚本,办公学习都可用,赶紧来看看吧!!

1.检查集群当前进程脚本:

#!/bin/bash for host in hadoop102 hadoop103 hadoop104 do echo =============== $host =============== ssh $host jps $@ | grep -v Jps done #就是如此简单

2.Hadoop集群群起,群停脚本: 这里以3台机器为例

#!/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.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.各机器之间文件同步脚本:

#!/bin/bash #1. 判断参数个数 if [ $# -lt 1 ] then echo Not Enough Arguement! exit; fi #2. 遍历集群所有机器 for host in hadoop102 hadoop103 hadoop104 do echo ==================== $host ==================== #3. 遍历所有目录,挨个发送 for file in $@ do #4. 判断文件是否存在 if [ -e $file ] then #5. 获取父目录 pdir=$(cd -P $(dirname $file); pwd) #6. 获取当前文件的名称 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台机器为例:

#!/bin/bash if [ $# -lt 1 ] 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群起,群停脚本:

#!/bin/bash if [ $# -lt 1 ] 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

觉得有用的小伙伴可以的收藏和关注哦 后面整理完持续更新。。。。

最新回复(0)