From 423d7ea3a18ff9d1538d4a7bfcd1f5a72facd97e Mon Sep 17 00:00:00 2001 From: Jiajie Zhong Date: Fri, 3 Dec 2021 18:16:25 +0800 Subject: [PATCH] [deploy] Add export database type for before daemon file (#7151) * [deploy] Use install_config.conf export datasource properties Directly user install_config.conf to set spring datasource properties, delete datasource.properties file for more clearly * Remove unused properties --- .../dolphinscheduler/common/Constants.java | 1 - .../src/main/resources/datasource.properties | 69 ------------------- .../main/resources/config/install_config.conf | 17 ++--- .../service/quartz/QuartzExecutors.java | 2 - install.sh | 6 -- script/dolphinscheduler-daemon.sh | 1 + 6 files changed, 8 insertions(+), 88 deletions(-) delete mode 100644 dolphinscheduler-dao/src/main/resources/datasource.properties diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java index 56494d3640..d403572a68 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java @@ -402,7 +402,6 @@ public final class Constants { /** * datasource configuration path */ - public static final String DATASOURCE_PROPERTIES = "/datasource.properties"; public static final String COMMON_TASK_TYPE = "common"; diff --git a/dolphinscheduler-dao/src/main/resources/datasource.properties b/dolphinscheduler-dao/src/main/resources/datasource.properties deleted file mode 100644 index 6720080806..0000000000 --- a/dolphinscheduler-dao/src/main/resources/datasource.properties +++ /dev/null @@ -1,69 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# datasource configuration -spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/dolphinscheduler -spring.datasource.username=root -spring.datasource.password=root - -# mysql example -#spring.datasource.driver-class-name=com.mysql.jdbc.Driver -#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dolphinscheduler?useUnicode=true&characterEncoding=UTF-8 -#spring.datasource.username=ds_user -#spring.datasource.password=dolphinscheduler - -# connection configuration -#spring.datasource.initialSize=5 -# min connection number -#spring.datasource.minIdle=5 -# max connection number -#spring.datasource.maxActive=50 - -# max wait time for get a connection in milliseconds. if configuring maxWait, fair locks are enabled by default and concurrency efficiency decreases. -# If necessary, unfair locks can be used by configuring the useUnfairLock attribute to true. -#spring.datasource.maxWait=60000 - -# milliseconds for check to close free connections -#spring.datasource.timeBetweenEvictionRunsMillis=60000 - -# the Destroy thread detects the connection interval and closes the physical connection in milliseconds if the connection idle time is greater than or equal to minEvictableIdleTimeMillis. -#spring.datasource.timeBetweenConnectErrorMillis=60000 - -# the longest time a connection remains idle without being evicted, in milliseconds -#spring.datasource.minEvictableIdleTimeMillis=300000 - -#the SQL used to check whether the connection is valid requires a query statement. If validation Query is null, testOnBorrow, testOnReturn, and testWhileIdle will not work. -#spring.datasource.validationQuery=SELECT 1 - -#check whether the connection is valid for timeout, in seconds -#spring.datasource.validationQueryTimeout=3 - -# when applying for a connection, if it is detected that the connection is idle longer than time Between Eviction Runs Millis, -# validation Query is performed to check whether the connection is valid -#spring.datasource.testWhileIdle=true - -#execute validation to check if the connection is valid when applying for a connection -#spring.datasource.testOnBorrow=true -#execute validation to check if the connection is valid when the connection is returned -#spring.datasource.testOnReturn=false -#spring.datasource.defaultAutoCommit=true -#spring.datasource.keepAlive=true - -# open PSCache, specify count PSCache for every connection -#spring.datasource.poolPreparedStatements=true -#spring.datasource.maxPoolPreparedStatementPerConnectionSize=20 diff --git a/dolphinscheduler-server/src/main/resources/config/install_config.conf b/dolphinscheduler-server/src/main/resources/config/install_config.conf index 91d60cf2db..b21c3f3b64 100755 --- a/dolphinscheduler-server/src/main/resources/config/install_config.conf +++ b/dolphinscheduler-server/src/main/resources/config/install_config.conf @@ -76,19 +76,16 @@ apiServerPort="12345" # --------------------------------------------------------- # The type for the metadata database # Supported values: ``postgresql``, ``mysql``. -dbtype="mysql" +DATABASE_TYPE="mysql" -# The : connection pair DolphinScheduler connect to the metadata database -dbhost="192.168.xx.xx:3306" +# Spring datasource url, following :/? format +SPRING_DATASOURCE_URL="jdbc:mysql://127.0.0.1:3306/dolphinscheduler?useUnicode=true&characterEncoding=UTF-8" -# The username DolphinScheduler connect to the metadata database -username="xx" +# Spring datasource username +SPRING_DATASOURCE_USERNAME="ds_user" -# The password DolphinScheduler connect to the metadata database -password="xx" - -# The database DolphinScheduler connect to the metadata database -dbname="dolphinscheduler" +# Spring datasource password +SPRING_DATASOURCE_PASSWORD="dolphinscheduler" # --------------------------------------------------------- # Registry Server diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java index d9d8619e12..9f49dd7939 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.service.quartz; -import static org.apache.dolphinscheduler.common.Constants.DATASOURCE_PROPERTIES; import static org.apache.dolphinscheduler.common.Constants.ORG_POSTGRESQL_DRIVER; import static org.apache.dolphinscheduler.common.Constants.ORG_QUARTZ_DATASOURCE_MYDS_CONNECTIONPROVIDER_CLASS; import static org.apache.dolphinscheduler.common.Constants.ORG_QUARTZ_JOBSTORE_ACQUIRETRIGGERSWITHINLOCK; @@ -150,7 +149,6 @@ public class QuartzExecutors { */ private void init() { try { - PropertyUtils.loadPropertyFile(DATASOURCE_PROPERTIES); StdSchedulerFactory schedulerFactory = new StdSchedulerFactory(); Properties properties = new Properties(); diff --git a/install.sh b/install.sh index 5574df53c4..a0cd9e4962 100755 --- a/install.sh +++ b/install.sh @@ -38,12 +38,6 @@ fi # Change configuration in conf/config/dolphinscheduler_env.sh sed -i ${txt} "s@^export JAVA_HOME=.*@export JAVA_HOME=${javaHome}@g" conf/env/dolphinscheduler_env.sh -# Change configuration in conf/datasource.properties -sed -i ${txt} "s@^spring.datasource.driver-class-name=.*@spring.datasource.driver-class-name=${datasourceDriverClassname}@g" conf/datasource.properties -sed -i ${txt} "s@^spring.datasource.url=.*@spring.datasource.url=jdbc:${dbtype}://${dbhost}/${dbname}?characterEncoding=UTF-8\&allowMultiQueries=true@g" conf/datasource.properties -sed -i ${txt} "s@^spring.datasource.username=.*@spring.datasource.username=${username}@g" conf/datasource.properties -sed -i ${txt} "s@^spring.datasource.password=.*@spring.datasource.password=${password}@g" conf/datasource.properties - # Change configuration in conf/common.properties sed -i ${txt} "s@^data.basedir.path=.*@data.basedir.path=${dataBasedirPath}@g" conf/common.properties sed -i ${txt} "s@^resource.storage.type=.*@resource.storage.type=${resourceStorageType}@g" conf/common.properties diff --git a/script/dolphinscheduler-daemon.sh b/script/dolphinscheduler-daemon.sh index 64d6b8327c..036bfd1070 100755 --- a/script/dolphinscheduler-daemon.sh +++ b/script/dolphinscheduler-daemon.sh @@ -37,6 +37,7 @@ DOLPHINSCHEDULER_HOME=`cd "$BIN_DIR/.."; pwd` source /etc/profile source "${DOLPHINSCHEDULER_HOME}/conf/env/dolphinscheduler_env.sh" +source "${DOLPHINSCHEDULER_HOME}/conf/config/install_config.conf" export HOSTNAME=`hostname`