From ec939fcc68a7587d4933d2e927a9f94ccff100d7 Mon Sep 17 00:00:00 2001
From: xiangzihao <460888207@qq.com>
Date: Sat, 16 Apr 2022 21:34:53 +0800
Subject: [PATCH] [Bug] [Dev] Fix start/stop/status/init script error (#9514)
* change /bin/sh to /bin/bash
* change /bin/sh to /bin/bash
* remove declear -A to adapt mac
---
.../src/main/assembly/dolphinscheduler-tools.xml | 2 +-
.../src/main/bin/create-schema.sh | 8 +++++---
.../src/main/bin/upgrade-schema.sh | 8 +++++---
script/dolphinscheduler-daemon.sh | 4 ++--
script/install.sh | 10 +++++-----
script/scp-hosts.sh | 4 +---
script/start-all.sh | 14 ++++++--------
script/status-all.sh | 12 +++++-------
script/stop-all.sh | 12 +++++-------
9 files changed, 35 insertions(+), 39 deletions(-)
diff --git a/dolphinscheduler-tools/src/main/assembly/dolphinscheduler-tools.xml b/dolphinscheduler-tools/src/main/assembly/dolphinscheduler-tools.xml
index bb822ba9b0..a24230c3cb 100644
--- a/dolphinscheduler-tools/src/main/assembly/dolphinscheduler-tools.xml
+++ b/dolphinscheduler-tools/src/main/assembly/dolphinscheduler-tools.xml
@@ -52,7 +52,7 @@
sql/**/*
- conf
+ sql
${basedir}/../dolphinscheduler-common/src/main/resources
diff --git a/dolphinscheduler-tools/src/main/bin/create-schema.sh b/dolphinscheduler-tools/src/main/bin/create-schema.sh
index efb12c9cdd..bfca27f9c1 100755
--- a/dolphinscheduler-tools/src/main/bin/create-schema.sh
+++ b/dolphinscheduler-tools/src/main/bin/create-schema.sh
@@ -17,10 +17,12 @@
#
BIN_DIR=$(dirname $0)
-DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)}
+DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/../..; pwd)}
-source "$BIN_DIR/dolphinscheduler_env.sh"
+source "$DOLPHINSCHEDULER_HOME/bin/env/dolphinscheduler_env.sh"
+
+JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"}
java $JAVA_OPTS \
- -cp "$DOLPHINSCHEDULER_HOME/conf":"$DOLPHINSCHEDULER_HOME/libs/*" \
+ -cp "$DOLPHINSCHEDULER_HOME/conf":"$DOLPHINSCHEDULER_HOME/tools/libs/*":"$DOLPHINSCHEDULER_HOME/tools/sql" \
org.apache.dolphinscheduler.tools.datasource.CreateDolphinScheduler
diff --git a/dolphinscheduler-tools/src/main/bin/upgrade-schema.sh b/dolphinscheduler-tools/src/main/bin/upgrade-schema.sh
index 691d71dc18..321fee919b 100755
--- a/dolphinscheduler-tools/src/main/bin/upgrade-schema.sh
+++ b/dolphinscheduler-tools/src/main/bin/upgrade-schema.sh
@@ -17,10 +17,12 @@
#
BIN_DIR=$(dirname $0)
-DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)}
+DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/../..; pwd)}
-source "$BIN_DIR/dolphinscheduler_env.sh"
+source "$DOLPHINSCHEDULER_HOME/bin/env/dolphinscheduler_env.sh"
+
+JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"}
java $JAVA_OPTS \
- -cp "$DOLPHINSCHEDULER_HOME/conf":"$DOLPHINSCHEDULER_HOME/libs/*" \
+ -cp "$DOLPHINSCHEDULER_HOME/conf":"$DOLPHINSCHEDULER_HOME/tools/libs/*":"$DOLPHINSCHEDULER_HOME/tools/sql" \
org.apache.dolphinscheduler.tools.datasource.UpgradeDolphinScheduler
diff --git a/script/dolphinscheduler-daemon.sh b/script/dolphinscheduler-daemon.sh
index 1ded5074fd..7f83f2bb8d 100755
--- a/script/dolphinscheduler-daemon.sh
+++ b/script/dolphinscheduler-daemon.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -69,7 +69,7 @@ fi
case $startStop in
(start)
echo starting $command, logging to $DOLPHINSCHEDULER_LOG_DIR
- nohup /bin/sh "$DOLPHINSCHEDULER_HOME/$command/bin/start.sh" > $log 2>&1 &
+ nohup /bin/bash "$DOLPHINSCHEDULER_HOME/$command/bin/start.sh" > $log 2>&1 &
echo $! > $pid
;;
diff --git a/script/install.sh b/script/install.sh
index 390ea7302b..16be44591d 100755
--- a/script/install.sh
+++ b/script/install.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -30,7 +30,7 @@ if [ ! -d $installPath ];then
fi
echo "2.scp resources"
-sh ${workDir}/scp-hosts.sh
+bash ${workDir}/scp-hosts.sh
if [ $? -eq 0 ];then
echo 'scp copy completed'
else
@@ -39,10 +39,10 @@ else
fi
echo "3.stop server"
-sh ${workDir}/stop-all.sh
+bash ${workDir}/stop-all.sh
echo "4.delete zk node"
-sh ${workDir}/remove-zk-node.sh $zkRoot
+bash ${workDir}/remove-zk-node.sh $zkRoot
echo "5.startup"
-sh ${workDir}/start-all.sh
+bash ${workDir}/start-all.sh
diff --git a/script/scp-hosts.sh b/script/scp-hosts.sh
index cbe658b62e..f5c5155c79 100755
--- a/script/scp-hosts.sh
+++ b/script/scp-hosts.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -27,8 +27,6 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
txt="''"
fi
-declare -A workersGroupMap=()
-
workersGroup=(${workers//,/ })
for workerGroup in ${workersGroup[@]}
do
diff --git a/script/start-all.sh b/script/start-all.sh
index 28edea95d0..bda5d31833 100755
--- a/script/start-all.sh
+++ b/script/start-all.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -21,8 +21,6 @@ workDir=`cd ${workDir};pwd`
source ${workDir}/env/install_env.sh
-declare -A workersGroupMap=()
-
workersGroup=(${workers//,/ })
for workerGroup in ${workersGroup[@]}
do
@@ -36,7 +34,7 @@ mastersHost=(${masters//,/ })
for master in ${mastersHost[@]}
do
echo "$master master server is starting"
- ssh -p $sshPort $master "cd $installPath/; sh bin/dolphinscheduler-daemon.sh start master-server;"
+ ssh -p $sshPort $master "cd $installPath/; bash bin/dolphinscheduler-daemon.sh start master-server;"
done
@@ -44,18 +42,18 @@ for worker in ${!workersGroupMap[*]}
do
echo "$worker worker server is starting"
- ssh -p $sshPort $worker "cd $installPath/; sh bin/dolphinscheduler-daemon.sh start worker-server;"
+ ssh -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh start worker-server;"
done
-ssh -p $sshPort $alertServer "cd $installPath/; sh bin/dolphinscheduler-daemon.sh start alert-server;"
+ssh -p $sshPort $alertServer "cd $installPath/; bash bin/dolphinscheduler-daemon.sh start alert-server;"
apiServersHost=(${apiServers//,/ })
for apiServer in ${apiServersHost[@]}
do
echo "$apiServer api server is starting"
- ssh -p $sshPort $apiServer "cd $installPath/; sh bin/dolphinscheduler-daemon.sh start api-server;"
+ ssh -p $sshPort $apiServer "cd $installPath/; bash bin/dolphinscheduler-daemon.sh start api-server;"
done
# query server status
echo "query server status"
-cd $installPath/; sh bin/status-all.sh
+cd $installPath/; bash bin/status-all.sh
diff --git a/script/status-all.sh b/script/status-all.sh
index afc522dd58..cc0eb03ffc 100755
--- a/script/status-all.sh
+++ b/script/status-all.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -37,8 +37,6 @@ firstColumn="node server state"
echo $firstColumn
echo -e '\n'
-declare -A workersGroupMap=()
-
workersGroup=(${workers//,/ })
for workerGroup in ${workersGroup[@]}
do
@@ -52,25 +50,25 @@ StateRunning="Running"
mastersHost=(${masters//,/ })
for master in ${mastersHost[@]}
do
- masterState=`ssh -p $sshPort $master "cd $installPath/; sh bin/dolphinscheduler-daemon.sh status master-server;"`
+ masterState=`ssh -p $sshPort $master "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status master-server;"`
echo "$master $masterState"
done
# 2.worker server check state
for worker in ${!workersGroupMap[*]}
do
- workerState=`ssh -p $sshPort $worker "cd $installPath/; sh 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"
done
# 3.alter server check state
-alertState=`ssh -p $sshPort $alertServer "cd $installPath/; sh bin/dolphinscheduler-daemon.sh status alert-server;"`
+alertState=`ssh -p $sshPort $alertServer "cd $installPath/; bash 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;"`
+ apiState=`ssh -p $sshPort $apiServer "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status api-server;"`
echo "$apiServer $apiState"
done
diff --git a/script/stop-all.sh b/script/stop-all.sh
index 6592374659..c58a05ee2c 100755
--- a/script/stop-all.sh
+++ b/script/stop-all.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -21,8 +21,6 @@ workDir=`cd ${workDir};pwd`
source ${workDir}/env/install_env.sh
-declare -A workersGroupMap=()
-
workersGroup=(${workers//,/ })
for workerGroup in ${workersGroup[@]}
do
@@ -36,21 +34,21 @@ mastersHost=(${masters//,/ })
for master in ${mastersHost[@]}
do
echo "$master master server is stopping"
- ssh -p $sshPort $master "cd $installPath/; sh bin/dolphinscheduler-daemon.sh stop master-server;"
+ ssh -p $sshPort $master "cd $installPath/; bash bin/dolphinscheduler-daemon.sh stop master-server;"
done
for worker in ${!workersGroupMap[*]}
do
echo "$worker worker server is stopping"
- ssh -p $sshPort $worker "cd $installPath/; sh bin/dolphinscheduler-daemon.sh stop worker-server;"
+ ssh -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh stop worker-server;"
done
-ssh -p $sshPort $alertServer "cd $installPath/; sh bin/dolphinscheduler-daemon.sh stop alert-server;"
+ssh -p $sshPort $alertServer "cd $installPath/; bash bin/dolphinscheduler-daemon.sh stop alert-server;"
apiServersHost=(${apiServers//,/ })
for apiServer in ${apiServersHost[@]}
do
echo "$apiServer api server is stopping"
- ssh -p $sshPort $apiServer "cd $installPath/; sh bin/dolphinscheduler-daemon.sh stop api-server;"
+ ssh -p $sshPort $apiServer "cd $installPath/; bash bin/dolphinscheduler-daemon.sh stop api-server;"
done