提交各组件部署Ansible剧本初版

This commit is contained in:
qidaijie
2024-01-18 15:35:33 +08:00
parent f0bd05d565
commit 0cc392df5c
262 changed files with 15927 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
#!/bin/bash
source /etc/profile
BASE_DIR={{ deploy_dir }}
VERSION={{ hadoop_version }}
function set_log(){
RES_SUM_FILE=$BASE_DIR/$VERSION/logs
if [ ! -f "$RES_SUM_FILE/" ]
then
mkdir -p $RES_SUM_FILE
fi
if [ ! -d "$RES_SUM_FILE/$1" ];then
echo "0" > $RES_SUM_FILE/$1
fi
OLD_NUM=`cat $RES_SUM_FILE/$1`
RESTART_NUM=`expr $OLD_NUM + 1`
echo $RESTART_NUM > $RES_SUM_FILE/$1
if [ $OLD_NUM -eq "0" ];then
echo "`date "+%Y-%m-%d %H:%M:%S"` - Yarn $2服务初次启动" >> $BASE_DIR/$VERSION/logs/restart.log
else
echo "`date +%Y-%m-%d` `date +%H:%M:%S` - Yarn $2服务异常 - 重启次数 -> $RESTART_NUM." >> $BASE_DIR/$VERSION/logs/restart.log
fi
}
while true ; do
HAS_HISTORY=`ps -ef | grep "org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer" | grep -v grep | wc -l`
if [ $HAS_HISTORY -eq "0" ];then
$BASE_DIR/$VERSION/sbin/mr-jobhistory-daemon.sh start historyserver > /dev/null
set_log nmRes_sum JobHistoryServer
fi
sleep 60
done

View File

@@ -0,0 +1,41 @@
#!/bin/bash
source /etc/profile
BASE_DIR={{ deploy_dir }}
VERSION={{ hadoop_version }}
function set_log(){
RES_SUM_FILE=$BASE_DIR/$VERSION/logs
if [ ! -f "$RES_SUM_FILE/" ]
then
mkdir -p $RES_SUM_FILE
fi
if [ ! -d "$RES_SUM_FILE/$1" ];then
echo "0" > $RES_SUM_FILE/$1
fi
OLD_NUM=`cat $RES_SUM_FILE/$1`
RESTART_NUM=`expr $OLD_NUM + 1`
echo $RESTART_NUM > $RES_SUM_FILE/$1
if [ $OLD_NUM -eq "0" ];then
echo "`date "+%Y-%m-%d %H:%M:%S"` - Yarn $2服务初次启动" >> $BASE_DIR/$VERSION/logs/restart.log
else
echo "`date +%Y-%m-%d` `date +%H:%M:%S` - Yarn $2服务异常 - 重启次数 -> $RESTART_NUM." >> $BASE_DIR/$VERSION/logs/restart.log
fi
}
while true ; do
HAS_RM=`ps -ef | grep "org.apache.hadoop.yarn.server.resourcemanager.ResourceManager" | grep -v grep | wc -l`
if [ $HAS_RM -eq "0" ];then
$BASE_DIR/$VERSION/sbin/yarn-daemon.sh start resourcemanager > /dev/null
set_log nmRes_sum ResourceManager
fi
sleep 60
done

View File

@@ -0,0 +1,41 @@
#!/bin/bash
source /etc/profile
BASE_DIR={{ deploy_dir }}
VERSION={{ hadoop_version }}
function set_log(){
RES_SUM_FILE=$BASE_DIR/$VERSION/logs
if [ ! -f "$RES_SUM_FILE/" ]
then
mkdir -p $RES_SUM_FILE
fi
if [ ! -d "$RES_SUM_FILE/$1" ];then
echo "0" > $RES_SUM_FILE/$1
fi
OLD_NUM=`cat $RES_SUM_FILE/$1`
RESTART_NUM=`expr $OLD_NUM + 1`
echo $RESTART_NUM > $RES_SUM_FILE/$1
if [ $OLD_NUM -eq "0" ];then
echo "`date "+%Y-%m-%d %H:%M:%S"` - Yarn $2服务初次启动" >> $BASE_DIR/$VERSION/logs/restart.log
else
echo "`date +%Y-%m-%d` `date +%H:%M:%S` - Yarn $2服务异常 - 重启次数 -> $RESTART_NUM." >> $BASE_DIR/$VERSION/logs/restart.log
fi
}
while true ; do
HAS_NM=`ps -ef | grep "org.apache.hadoop.yarn.server.nodemanager.NodeManager" | grep -v grep | wc -l`
if [ $HAS_NM -eq "0" ];then
$BASE_DIR/$VERSION/sbin/yarn-daemon.sh start nodemanager > /dev/null
set_log nmRes_sum NodeManager
fi
sleep 60
done

View File

@@ -0,0 +1,46 @@
#!/bin/bash
#
# netconsole This loads the netconsole module with the configured parameters.
#
# chkconfig:123456 40 60
# description: keepyarnhistory
source /etc/profile
PRO_NAME=keepyarnhistory
INS_DIR={{ deploy_dir }}
#版本
VERSION={{ hadoop_version }}
case $1 in
start)
master=`ps -ef | grep "dae-yarnhistory.sh" | grep -v grep | wc -l`
if [ $master -lt 1 ];then
nohup $INS_DIR/$VERSION/sbin/dae-yarnhistory.sh > /dev/null 2>&1 &
fi
;;
stop)
HAS_KEEP_SHELL=`ps -ef | grep "dae-yarnhistory.sh" | grep -v grep | awk '{print $2}'`
if [ $HAS_KEEP_SHELL ];then
echo "守护进程PID$HAS_KEEP_SHELL"
kill -9 $HAS_KEEP_SHELL
fi
sh $INS_DIR/$VERSION/sbin/mr-jobhistory-daemon.sh stop historyserver > /dev/null
;;
status)
HAS_HISTORY=`ps -ef | grep "org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer" | grep -v grep | wc -l`
if [ $HAS_HISTORY -eq "0" ];then
echo "JobHistoryServer not running!"
else
echo "JobHistoryServer is running!"
fi
;;
* )
echo "use keepyarnhistory [start|stop|status]"
;;
esac

View File

@@ -0,0 +1,40 @@
#!/bin/bash
#
# netconsole This loads the netconsole module with the configured parameters.
#
# chkconfig:123456 40 60
# description: keepyarnmaster
source /etc/profile
PRO_NAME=keepyarnmaster
INS_DIR={{ deploy_dir }}
#版本
VERSION={{ hadoop_version }}
case $1 in
start)
master=`ps -ef | grep "dae-yarnmaster.sh" | grep -v grep | wc -l`
if [ $master -lt 1 ];then
nohup $INS_DIR/$VERSION/sbin/dae-yarnmaster.sh > /dev/null 2>&1 &
fi
;;
stop)
HAS_KEEP_SHELL=`ps -ef | grep "dae-yarnmaster.sh" | grep -v grep | awk '{print $2}'`
if [ $HAS_KEEP_SHELL ];then
echo "守护进程PID$HAS_KEEP_SHELL"
kill -9 $HAS_KEEP_SHELL
fi
sh $INS_DIR/$VERSION/sbin/yarn-daemon.sh stop resourcemanager > /dev/null
;;
status)
yarn rmadmin -getServiceState rsm1
;;
* )
echo "use keepyarnmaster [start|stop|status]"
;;
esac

View File

@@ -0,0 +1,46 @@
#!/bin/bash
#
# netconsole This loads the netconsole module with the configured parameters.
#
# chkconfig:123456 40 60
# description: keepyarnworker
source /etc/profile
PRO_NAME=keepyarnworker
INS_DIR={{ deploy_dir }}
#版本
VERSION={{ hadoop_version }}
case $1 in
start)
master=`ps -ef | grep "dae-yarnworker.sh" | grep -v grep | wc -l`
if [ $master -lt 1 ];then
nohup $INS_DIR/$VERSION/sbin/dae-yarnworker.sh > /dev/null 2>&1 &
fi
;;
stop)
HAS_KEEP_SHELL=`ps -ef | grep "dae-yarnworker.sh" | grep -v grep | awk '{print $2}'`
if [ $HAS_KEEP_SHELL ];then
echo "守护进程PID$HAS_KEEP_SHELL"
kill -9 $HAS_KEEP_SHELL
fi
sh $INS_DIR/$VERSION/sbin/yarn-daemon.sh stop nodemanager > /dev/null
;;
status)
HAS_NM=`ps -ef | grep "org.apache.hadoop.yarn.server.nodemanager.NodeManager" | grep -v grep | wc -l`
if [ $HAS_NM -eq "0" ];then
echo "NodeManager not running!"
else
echo "NodeManager is running!"
fi
;;
* )
echo "use keepyarnworker [start|stop|status]"
;;
esac