From 908dba4ba67c8fb319890a731ecd12061af9fc58 Mon Sep 17 00:00:00 2001 From: zhuangchong <37063904+zhuangchong@users.noreply.github.com> Date: Mon, 31 Aug 2020 16:54:45 +0800 Subject: [PATCH] [Improvement][install,start-all,stop-all] start- all.sh and stop- all.sh After execution, you can view the running status of each node and service. #3619 (#3627) * start- all.sh and stop- all.sh After execution, you can view the running status of each node and service. * ds server state check. --- install.sh | 4 --- script/dolphinscheduler-daemon.sh | 19 +++++++--- script/start-all.sh | 6 +++- script/status-all.sh | 59 +++++++++++++++++++++++++------ script/stop-all.sh | 6 +++- 5 files changed, 73 insertions(+), 21 deletions(-) diff --git a/install.sh b/install.sh index ae16a1d199..da21085d14 100755 --- a/install.sh +++ b/install.sh @@ -98,7 +98,3 @@ sh ${workDir}/script/remove-zk-node.sh $zkRoot # 6.startup echo "6.startup" sh ${workDir}/script/start-all.sh - -# 7.query status -echo "7.query status" -sh ${workDir}/script/status-all.sh diff --git a/script/dolphinscheduler-daemon.sh b/script/dolphinscheduler-daemon.sh index 8c96764336..26c751f6e5 100644 --- a/script/dolphinscheduler-daemon.sh +++ b/script/dolphinscheduler-daemon.sh @@ -16,7 +16,7 @@ # limitations under the License. # -usage="Usage: dolphinscheduler-daemon.sh (start|stop) " +usage="Usage: dolphinscheduler-daemon.sh (start|stop|status) " # if no args specified, show usage if [ $# -le 1 ]; then @@ -29,7 +29,6 @@ shift command=$1 shift -echo "Begin $startStop $command......" BIN_DIR=`dirname $0` BIN_DIR=`cd "$BIN_DIR"; pwd` @@ -122,11 +121,23 @@ case $startStop in fi ;; + (status) + # more details about the status can be added later + serverCount=`ps -ef |grep "$CLASS" |grep -v "grep" |wc -l` + state="STOP" + # font color - red + state="[ \033[1;31m $state \033[0m ]" + if [[ $serverCount -gt 0 ]];then + state="RUNNING" + # font color - green + state="[ \033[1;32m $state \033[0m ]" + fi + echo -e "$command $state" + ;; + (*) echo $usage exit 1 ;; esac - -echo "End $startStop $command." diff --git a/script/start-all.sh b/script/start-all.sh index 61b916483e..d0c0ab8188 100644 --- a/script/start-all.sh +++ b/script/start-all.sh @@ -54,4 +54,8 @@ for apiServer in ${apiServersHost[@]} do echo "$apiServer worker server is starting" ssh -p $sshPort $apiServer "cd $installPath/; sh bin/dolphinscheduler-daemon.sh start api-server;" -done \ No newline at end of file +done + +# query server status +echo "query server status" +cd $installPath/; sh bin/status-all.sh diff --git a/script/status-all.sh b/script/status-all.sh index 64dfaa46b8..555a2c1ead 100644 --- a/script/status-all.sh +++ b/script/status-all.sh @@ -20,22 +20,59 @@ workDir=`dirname $0` workDir=`cd ${workDir};pwd` source $workDir/../conf/config/install_config.conf +# install_config.conf info echo -e '\n' -echo "====================== dolphinscheduler install config=============================" -echo -e "1.dolphinscheduler server node install hosts:[ \033[1;32m ${ips} \033[0m ]" -echo -e "2.master server node install hosts:[ \033[1;32m ${masters} \033[0m ]" -echo -e "3.worker server node install hosts:[ \033[1;32m ${workers} \033[0m ]" -echo -e "4.alert server node install hosts:[ \033[1;32m ${alertServer} \033[0m ]" -echo -e "5.api server node install hosts:[ \033[1;32m ${apiServers} \033[0m ]" +echo "====================== dolphinscheduler server config =============================" +echo -e "1.dolphinscheduler server node config hosts:[ \033[1;32m ${ips} \033[0m ]" +echo -e "2.master server node config hosts:[ \033[1;32m ${masters} \033[0m ]" +echo -e "3.worker server node config hosts:[ \033[1;32m ${workers} \033[0m ]" +echo -e "4.alert server node config hosts:[ \033[1;32m ${alertServer} \033[0m ]" +echo -e "5.api server node config hosts:[ \033[1;32m ${apiServers} \033[0m ]" +# all server check state echo -e '\n' +echo "====================== dolphinscheduler server status =============================" +firstColumn="node server state" +echo $firstColumn +echo -e '\n' + +declare -A workersGroupMap=() +workersGroup=(${workers//,/ }) +for workerGroup in ${workersGroup[@]} +do + worker=`echo $workerGroup|awk -F':' '{print $1}'` + groupName=`echo $workerGroup|awk -F':' '{print $2}'` + workersGroupMap+=([$worker]=$groupName) +done -ipsHost=(${ips//,/ }) -for ip in ${ipsHost[@]} +StateRunning="Running" +# 1.master server check state +mastersHost=(${masters//,/ }) +for master in ${mastersHost[@]} do - echo -e "====================== [ \033[1;32m ${ip} \033[0m ] node all servers ==========================" - ssh -p $sshPort $ip "jps" - echo -e '\n' + masterState=`ssh -p $sshPort $master "cd $installPath/; sh bin/dolphinscheduler-daemon.sh status master-server;"` + echo "$master $masterState" done +# 2.worker server and logger-server check state +for worker in ${!workersGroupMap[*]} +do + workerState=`ssh -p $sshPort $worker "cd $installPath/; sh bin/dolphinscheduler-daemon.sh status worker-server;"` + echo "$worker $workerState" + + masterState=`ssh -p $sshPort $worker "cd $installPath/; sh bin/dolphinscheduler-daemon.sh status logger-server;"` + echo "$worker $masterState" +done + +# 3.alter server check state +alertState=`ssh -p $sshPort $alertServer "cd $installPath/; sh bin/dolphinscheduler-daemon.sh status alert-server;"` +echo "$alertServer $alertState" + +# 4.api server check state +apiServersHost=(${apiServers//,/ }) +for apiServer in ${apiServersHost[@]} +do + apiState=`ssh -p $sshPort $apiServer "cd $installPath/; sh bin/dolphinscheduler-daemon.sh status api-server;"` + echo "$apiServer $apiState" +done diff --git a/script/stop-all.sh b/script/stop-all.sh index dc18dae586..20175e9a51 100644 --- a/script/stop-all.sh +++ b/script/stop-all.sh @@ -54,4 +54,8 @@ for apiServer in ${apiServersHost[@]} do echo "$apiServer worker server is stopping" ssh -p $sshPort $apiServer "cd $installPath/; sh bin/dolphinscheduler-daemon.sh stop api-server;" -done \ No newline at end of file +done + +# query server status +echo "query server status" +cd $installPath/; sh bin/status-all.sh