3月30
#! /bin/sh base_dir=$(cd "$(dirname $0)"; pwd) export JAVA_HOME=/usr/java/jdk1.8.0_51 export PATH=/root/anaconda3/bin:/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin ##############jar文件名称 cd $base_dir #version=1.2.0 version=$(echo $packagename | awk -F[Vv] '{print $2}' | cut -d "." -f 1-3) app=$(find -maxdepth 1 -type f -name "SSBK-Streaming-$version*.jar") app_name=${app##*/} echo $app_name ###########kill进程 echo "${app_name}准备升级中..." pid_all=$(ps -ef|grep ${app_name}|grep -v "grep"|awk '{print $2}') app_id=$(yarn application -list | grep "application_" | egrep "DataObject|Intelligent" | awk '{print $1}') echo "$app_id" > app_id.txt pid_all=$( cat app_id.txt) if [ -n "${pid_all}" ];then for pid in ${pid_all[@]}; do echo "The pid is running,start kill pid:${pid} for ${app_name}..." yarn application -kill ${pid} done fi echo "${app_name}正在升级中..." #####启动程序 nohup spark2-submit --master yarn --deploy-mode cluster --class com.chinaoly.ssbkStreaming.runner.OutputResultJobRunner --name OutputResultJobRunner --driver-memory 1G --executor-memory 2G --num-executors 2 /home/chinaoly/${app_name} > logs/OutputResultJobRunner.log 2>&1 & sleep 10 nohup spark2-submit --master yarn --deploy-mode cluster --class com.chinaoly.ssbkStreaming.runner.RyztJobRunner --name RyztJobRunner --driver-memory 2G --executor-memory 2G --num-executors 2 /home/chinaoly/${app_name} > logs/RyztJobRunner.log 2>&1 & sleep 10 nohup spark2-submit --master yarn --deploy-mode cluster --class com.chinaoly.ssbkStreaming.runner.TagJobRunner --name TagJobRunner --driver-memory 1G --executor-memory 2G --num-executors 2 /home/chinaoly/${app_name} > logs/TagJobRunner.log 2>&1 & sleep 10 nohup spark2-submit --master yarn --deploy-mode cluster --class com.chinaoly.ssbkStreaming.runner.TargetJobRunner --name TargetJobRunner --driver-memory 1G --executor-memory 2G --num-executors 2 /home/chinaoly/${app_name} > logs/TargetJobRunner.log 2>&1 & sleep 10 pid=$(ps -ef|grep ${app_name}|grep -v "grep"|awk '{print $2}') if [ -n "${pid}" ]; then echo "==========${app_name}启动成功!进程ID:$pid=================" else echo "==========${app_name}启动出错!================" exit 1 fi
########## 今天的苦逼是为了不这样一直苦逼下去!##########