Browse Source

[Bug][Script] Fix the type of variable workersGroupMap is not supported in bash 3.x (#9614)

3.0.0/version-upgrade
Paul Zhang 3 years ago committed by GitHub
parent
commit
cc40816f87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      script/scp-hosts.sh
  2. 5
      script/start-all.sh
  3. 5
      script/status-all.sh
  4. 5
      script/stop-all.sh

27
script/scp-hosts.sh

@ -21,19 +21,14 @@ workDir=`cd ${workDir};pwd`
source ${workDir}/env/install_env.sh source ${workDir}/env/install_env.sh
txt=""
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
txt="''"
fi
workersGroup=(${workers//,/ }) workersGroup=(${workers//,/ })
for workerGroup in ${workersGroup[@]} for workerGroup in ${workersGroup[@]}
do do
echo $workerGroup; echo $workerGroup;
worker=`echo $workerGroup|awk -F':' '{print $1}'` worker=`echo $workerGroup|awk -F':' '{print $1}'`
groupsName=`echo $workerGroup|awk -F':' '{print $2}'` group=`echo $workerGroup|awk -F':' '{print $2}'`
workersGroupMap+=([$worker]=$groupsName) workerNames+=($worker)
groupNames+=(${group:-default})
done done
hostsArr=(${ips//,/ }) hostsArr=(${ips//,/ })
@ -47,17 +42,23 @@ do
echo "scp dirs to $host/$installPath starting" echo "scp dirs to $host/$installPath starting"
ssh -p $sshPort $host "cd $installPath/; rm -rf bin/ conf/ lib/ script/ sql/ ui/" 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 for i in ${!workerNames[@]}; do
do if [[ ${workerNames[$i]} == $host ]]; then
# if worker in workersGroupMap workerIndex=$i
if [[ "${workersGroupMap[${host}]}" ]]; then break
echo "export WORKER_GROUPS_0=${workersGroupMap[${host}]}" >> worker-server/bin/dolphinscheduler_env.sh
fi 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" echo "start to scp $dsDir to $host/$installPath"
# Use quiet mode to reduce command line output # Use quiet mode to reduce command line output
scp -q -P $sshPort -r $workDir/../$dsDir $host:$installPath scp -q -P $sshPort -r $workDir/../$dsDir $host:$installPath
done 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" echo "scp dirs to $host/$installPath complete"
done done

5
script/start-all.sh

@ -26,8 +26,7 @@ for workerGroup in ${workersGroup[@]}
do do
echo $workerGroup; echo $workerGroup;
worker=`echo $workerGroup|awk -F':' '{print $1}'` worker=`echo $workerGroup|awk -F':' '{print $1}'`
groupName=`echo $workerGroup|awk -F':' '{print $2}'` workerNames+=($worker)
workersGroupMap+=([$worker]=$groupName)
done done
mastersHost=(${masters//,/ }) mastersHost=(${masters//,/ })
@ -38,7 +37,7 @@ do
done done
for worker in ${!workersGroupMap[*]} for worker in ${workerNames[@]}
do do
echo "$worker worker server is starting" echo "$worker worker server is starting"

5
script/status-all.sh

@ -41,8 +41,7 @@ workersGroup=(${workers//,/ })
for workerGroup in ${workersGroup[@]} for workerGroup in ${workersGroup[@]}
do do
worker=`echo $workerGroup|awk -F':' '{print $1}'` worker=`echo $workerGroup|awk -F':' '{print $1}'`
groupName=`echo $workerGroup|awk -F':' '{print $2}'` workerNames+=($worker)
workersGroupMap+=([$worker]=$groupName)
done done
StateRunning="Running" StateRunning="Running"
@ -55,7 +54,7 @@ do
done done
# 2.worker server check state # 2.worker server check state
for worker in ${!workersGroupMap[*]} for worker in ${workerNames[@]}
do do
workerState=`ssh -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status worker-server;"` workerState=`ssh -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status worker-server;"`
echo "$worker $workerState" echo "$worker $workerState"

5
script/stop-all.sh

@ -26,8 +26,7 @@ for workerGroup in ${workersGroup[@]}
do do
echo $workerGroup; echo $workerGroup;
worker=`echo $workerGroup|awk -F':' '{print $1}'` worker=`echo $workerGroup|awk -F':' '{print $1}'`
groupName=`echo $workerGroup|awk -F':' '{print $2}'` workerNames+=($worker)
workersGroupMap+=([$worker]=$groupName)
done done
mastersHost=(${masters//,/ }) mastersHost=(${masters//,/ })
@ -38,7 +37,7 @@ do
done done
for worker in ${!workersGroupMap[*]} for worker in ${workerNames[@]}
do do
echo "$worker worker server is stopping" echo "$worker worker server is stopping"
ssh -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh stop worker-server;" ssh -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh stop worker-server;"

Loading…
Cancel
Save