Problem Description
After restarting the DolphinScheduler 3.1.9 standalone version, all data such as projects and workflow definitions are lost.
Cause of the Problem
By default, the configuration uses the H2 in-memory database, meaning data is stored only in memory and becomes invalid after a restart.
sql:
init:
schema-locations: classpath:sql/dolphinscheduler_h2.sql
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:dolphinscheduler;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true
username: sa
password: ""
Solution
1. Modify the Database Configuration
Edit standalone-server/conf/application.yaml
, replace the H2 configuration with MySQL, and modify the database settings accordingly.
Notes:
- Change the
url
to your own MySQL hostname and database name (it’s not recommended to change the default name); keep the other parts unchanged. - Update
username
andpassword
with your own MySQL credentials. - Since the
schema-locations
section refers to MySQL instead of H2, you can copy and paste it directly. - The YAML file is parsed using SnakeYAML, so make sure the indentation is correct. It’s recommended to back up the configuration file before making any changes.
sql:
init:
schema-locations: classpath:sql/dolphinscheduler_mysql.sql
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/dolphinscheduler?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: "123456"
2. Create the MySQL Database
Run the following SQL command to create the database (make sure the character set is correct):
CREATE DATABASE dolphinscheduler DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
3. Add the MySQL Driver
Place the mysql-connector-java-*.jar
file into the following directories:
tools/libs/
standalone-server/libs/
4. Initialize the Database
Run the upgrade script to import the table structure into MySQL:
bash tools/bin/upgrade-schema.sh mysql
Notes:
- Make sure the MySQL service is running and the network connection is available. Replace the MySQL host, username, and password in the configuration with your actual values.
- After completing the above steps, restart the DolphinScheduler service to enable data persistence.
If this article helps you, please give it a like or follow. Thank you.
Top comments (0)