From cc40816f87d1251ef2028b5d7e89805e6630a694 Mon Sep 17 00:00:00 2001 From: Paul Zhang Date: Mon, 25 Apr 2022 11:32:09 +0800 Subject: [PATCH] [Bug][Script] Fix the type of variable workersGroupMap is not supported in bash 3.x (#9614) --- script/scp-hosts.sh | 27 ++++++++++++++------------- script/start-all.sh | 5 ++--- script/status-all.sh | 5 ++--- script/stop-all.sh | 5 ++--- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/script/scp-hosts.sh b/script/scp-hosts.sh index f5c5155c79..a9499196d8 100755 --- a/script/scp-hosts.sh +++ b/script/scp-hosts.sh @@ -21,19 +21,14 @@ workDir=`cd ${workDir};pwd` source ${workDir}/env/install_env.sh -txt="" -if [[ "$OSTYPE" == "darwin"* ]]; then - # Mac OSX - txt="''" -fi - workersGroup=(${workers//,/ }) for workerGroup in ${workersGroup[@]} do echo $workerGroup; worker=`echo $workerGroup|awk -F':' '{print $1}'` - groupsName=`echo $workerGroup|awk -F':' '{print $2}'` - workersGroupMap+=([$worker]=$groupsName) + group=`echo $workerGroup|awk -F':' '{print $2}'` + workerNames+=($worker) + groupNames+=(${group:-default}) done hostsArr=(${ips//,/ }) @@ -47,17 +42,23 @@ do echo "scp dirs to $host/$installPath starting" ssh -p $sshPort $host "cd $installPath/; rm -rf bin/ conf/ lib/ script/ sql/ ui/" - for dsDir in bin master-server worker-server alert-server api-server ui - do - # if worker in workersGroupMap - if [[ "${workersGroupMap[${host}]}" ]]; then - echo "export WORKER_GROUPS_0=${workersGroupMap[${host}]}" >> worker-server/bin/dolphinscheduler_env.sh + for i in ${!workerNames[@]}; do + if [[ ${workerNames[$i]} == $host ]]; then + workerIndex=$i + break fi + done + # set worker groups in application.yaml + [[ -n ${workerIndex} ]] && sed -i "s/- default/- ${groupNames[$workerIndex]}/" worker-server/conf/application.yaml + for dsDir in bin master-server worker-server alert-server api-server ui + do echo "start to scp $dsDir to $host/$installPath" # Use quiet mode to reduce command line output scp -q -P $sshPort -r $workDir/../$dsDir $host:$installPath done + # restore worker groups to default + [[ -n ${workerIndex} ]] && sed -i "s/- ${groupNames[$workerIndex]}/- default/" worker-server/conf/application.yaml echo "scp dirs to $host/$installPath complete" done diff --git a/script/start-all.sh b/script/start-all.sh index bda5d31833..35936eea0a 100755 --- a/script/start-all.sh +++ b/script/start-all.sh @@ -26,8 +26,7 @@ for workerGroup in ${workersGroup[@]} do echo $workerGroup; worker=`echo $workerGroup|awk -F':' '{print $1}'` - groupName=`echo $workerGroup|awk -F':' '{print $2}'` - workersGroupMap+=([$worker]=$groupName) + workerNames+=($worker) done mastersHost=(${masters//,/ }) @@ -38,7 +37,7 @@ do done -for worker in ${!workersGroupMap[*]} +for worker in ${workerNames[@]} do echo "$worker worker server is starting" diff --git a/script/status-all.sh b/script/status-all.sh index cc0eb03ffc..7f3f184094 100755 --- a/script/status-all.sh +++ b/script/status-all.sh @@ -41,8 +41,7 @@ workersGroup=(${workers//,/ }) for workerGroup in ${workersGroup[@]} do worker=`echo $workerGroup|awk -F':' '{print $1}'` - groupName=`echo $workerGroup|awk -F':' '{print $2}'` - workersGroupMap+=([$worker]=$groupName) + workerNames+=($worker) done StateRunning="Running" @@ -55,7 +54,7 @@ do done # 2.worker server check state -for worker in ${!workersGroupMap[*]} +for worker in ${workerNames[@]} do workerState=`ssh -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status worker-server;"` echo "$worker $workerState" diff --git a/script/stop-all.sh b/script/stop-all.sh index c58a05ee2c..ee3a09cd41 100755 --- a/script/stop-all.sh +++ b/script/stop-all.sh @@ -26,8 +26,7 @@ for workerGroup in ${workersGroup[@]} do echo $workerGroup; worker=`echo $workerGroup|awk -F':' '{print $1}'` - groupName=`echo $workerGroup|awk -F':' '{print $2}'` - workersGroupMap+=([$worker]=$groupName) + workerNames+=($worker) done mastersHost=(${masters//,/ }) @@ -38,7 +37,7 @@ do done -for worker in ${!workersGroupMap[*]} +for worker in ${workerNames[@]} do echo "$worker worker server is stopping" ssh -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh stop worker-server;"