{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreigae4v66bhnblrfgeky64mjtcma3gnqcrxd6sbf4veserp34zwnoe",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mokd5a52ods2"
},
"path": "/chen_debra_3060b21d12b1b0/deploying-apache-dolphinscheduler-319-cluster-with-mysql-instead-of-postgresql-a-practical-2mam",
"publishedAt": "2026-06-18T07:37:46.000Z",
"site": "https://dev.to",
"tags": [
"mysql",
"apachedolphinscheduler",
"doris",
"postgressql"
],
"textContent": "## Background\n\nToday, we'll walk through one of the most requested deployment scenarios in the Apache DolphinScheduler community: deploying an Apache DolphinScheduler 3.1.9 cluster with MySQL as the metadata database using Docker Compose.\n\nAs many users know, the official Docker Compose deployment provided by DolphinScheduler uses PostgreSQL as the metadata repository by default. This is mainly because the GPLv2 license of MySQL is not fully compatible with Apache License 2.0, preventing the project from distributing an official MySQL-based package.\n\nHowever, in real-world production environments, many organizations prefer MySQL due to its mature ecosystem, extensive tooling, operational familiarity, and widespread adoption across enterprises.\n\nIn this guide, we'll show how to adapt the official Docker Compose deployment and successfully run a DolphinScheduler cluster backed by MySQL metadata storage.\n\n## Pull Required Images\n\n\n docker pull apache/dolphinscheduler-master:3.1.9\n\n docker pull apache/dolphinscheduler-worker:3.1.9\n\n docker pull apache/dolphinscheduler-tools:3.1.9\n\n docker pull apache/dolphinscheduler-api:3.1.9\n\n docker pull apache/dolphinscheduler-alert-server:3.1.9\n\n docker pull bitnami/zookeeper:3.7.1\n\n\n## Download the MySQL JDBC Driver\n\n\n wget https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-j-8.0.33.zip\n\n unzip -q mysql-connector-j-8.0.33.zip\n\n cp mysql-connector-j-8.0.33/mysql-connector-j-8.0.33.jar .\n\n\n## Prepare Custom Images\n\n### Dockerfile for Master, Worker, API, and Alert Server\n\n\n # Based on the official DolphinScheduler image\n\n ARG SERVICE=api\n\n FROM apache/dolphinscheduler-${SERVICE}:3.1.9\n\n # Copy the MySQL JDBC driver into the DolphinScheduler library directory\n\n # DolphinScheduler loads JDBC drivers from the lib directory\n\n COPY mysql-connector-j-8.0.33.jar /opt/dolphinscheduler/libs/\n\n\n### Dockerfile for Tools\n\n\n # Based on the official DolphinScheduler image\n\n ARG SERVICE=tools\n\n FROM apache/dolphinscheduler-${SERVICE}:3.1.9\n\n # Copy the MySQL JDBC driver into the DolphinScheduler tools library directory\n\n # DolphinScheduler loads JDBC drivers from the lib directory\n\n COPY mysql-connector-j-8.0.33.jar /opt/dolphinscheduler/tools/libs/\n\n\n## Build Custom Images\n\n\n docker build --build-arg SERVICE=master -t apache/dolphinscheduler-master:3.1.9-mysql .\n\n docker build --build-arg SERVICE=worker -t apache/dolphinscheduler-worker:3.1.9-mysql .\n\n docker build --build-arg SERVICE=tools -t apache/dolphinscheduler-tools:3.1.9-mysql .\n\n docker build --build-arg SERVICE=api -t apache/dolphinscheduler-api:3.1.9-mysql .\n\n docker build --build-arg SERVICE=alert-server -t apache/dolphinscheduler-alert-server:3.1.9-mysql .\n\n\n## Update docker-compose.yaml\n\nDisable the PostgreSQL service and add a MySQL service as the metadata database.\n\n\n\n # Comment out the PostgreSQL service\n\n # dolphinscheduler-postgresql:\n # image: bitnami/postgresql:15.2.0\n # ...\n\n # MySQL Metadata Database Service\n\n dolphinscheduler-mysql:\n image: mysql:8.0\n container_name: dolphinscheduler-mysql\n\n profiles:\n - all\n - schema\n\n environment:\n MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}\n MYSQL_DATABASE: ${MYSQL_DATABASE:-dolphinscheduler}\n\n volumes:\n - dolphinscheduler-mysql:/var/lib/mysql\n\n ports:\n - \"3306:3306\"\n\n # Expose MySQL to allow workers on other servers to connect\n\n healthcheck:\n test:\n [\n \"CMD\",\n \"mysqladmin\",\n \"ping\",\n \"-h\",\n \"localhost\",\n \"-u\",\n \"${MYSQL_USERNAME:-root}\",\n \"-p${MYSQL_PASSWORD:-root}\"\n ]\n\n interval: 5s\n timeout: 60s\n retries: 120\n\n networks:\n - dolphinscheduler\n\n\nThe remaining services (ZooKeeper, Schema Initializer, API, Alert Server, Master, Worker, Network, and Volume configurations) remain the same as the official Docker Compose deployment, with the following key modifications:\n\n### Schema Initializer Dependency\n\n\n depends_on:\n dolphinscheduler-mysql:\n condition: service_healthy\n\n\n### Master JVM Configuration\n\n\n environment:\n JAVA_OPTS: >\n -server\n -Duser.timezone=${SPRING_JACKSON_TIME_ZONE}\n -Xms8g\n -Xmx8g\n -Xmn4g\n -XX:+PrintGCDetails\n -Xloggc:gc.log\n -XX:+HeapDumpOnOutOfMemoryError\n -XX:HeapDumpPath=dump.hprof\n\n\n### Worker JVM Configuration\n\n\n environment:\n JAVA_OPTS: >\n -server\n -Duser.timezone=${SPRING_JACKSON_TIME_ZONE}\n -Xms8g\n -Xmx8g\n -Xmn4g\n -XX:+PrintGCDetails\n -Xloggc:gc.log\n -XX:+HeapDumpOnOutOfMemoryError\n -XX:HeapDumpPath=dump.hprof\n\n\n### Volume Configuration\n\n\n volumes:\n # Comment out PostgreSQL volume\n\n # dolphinscheduler-postgresql:\n\n dolphinscheduler-mysql:\n dolphinscheduler-zookeeper:\n dolphinscheduler-worker-data:\n dolphinscheduler-logs:\n dolphinscheduler-shared-local:\n\n\n## Update the .env File\n\n\n # Docker Hub Repository and Image Tag\n\n HUB=apache\n TAG=3.1.9\n\n # MySQL Configuration\n\n MYSQL_ROOT_PASSWORD=root\n MYSQL_DATABASE=dolphinscheduler\n MYSQL_USERNAME=root\n MYSQL_PASSWORD=root\n\n # DolphinScheduler Database Configuration\n\n TZ=Asia/Shanghai\n\n # Use MySQL as the metadata database\n\n DATABASE=mysql\n\n SPRING_JACKSON_TIME_ZONE=GMT+8\n\n SPRING_DATASOURCE_URL=jdbc:mysql://dolphinscheduler-mysql:3306/${MYSQL_DATABASE}?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true\n\n SPRING_DATASOURCE_USERNAME=${MYSQL_USERNAME}\n\n SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD}\n\n REGISTRY_ZOOKEEPER_CONNECT_STRING=dolphinscheduler-zookeeper:2181\n\n MASTER_FETCH_COMMAND_NUM=10\n\n\n## Initialize the Database\n\n\n docker compose --profile schema up -d\n\n\n## Start the Entire Cluster\n\n\n docker compose --profile all up -d\n\n\n## Start the Worker Service\n\n\n docker compose up -d dolphinscheduler-worker\n\n\n## Start the Master Service\n\n\n docker compose up -d dolphinscheduler-master\n\n\n## Start the Alert Service\n\n\n docker compose up -d dolphinscheduler-alert\n\n\n## Start the API Service\n\n\n docker compose up -d dolphinscheduler-api\n\n\n## Restart All Services\n\n\n docker compose --profile all restart\n\n\n## Conclusion\n\nAlthough Apache DolphinScheduler officially ships with a PostgreSQL-based Docker Compose deployment, many enterprises continue to standardize on MySQL for operational consistency and ecosystem compatibility.\n\nBy adding the MySQL JDBC driver, rebuilding the DolphinScheduler images, and adjusting the Docker Compose and environment configurations, you can quickly deploy a fully functional Apache DolphinScheduler 3.1.9 cluster powered by MySQL metadata storage.\n\nThis approach enables teams already invested in the MySQL ecosystem to integrate DolphinScheduler into their infrastructure with minimal friction while preserving the benefits of containerized deployment and cluster-based scheduling.\n\nIf your organization relies on MySQL as a strategic database platform, this solution provides a practical and production-friendly path to running Apache DolphinScheduler at scale.",
"title": "Deploying Apache DolphinScheduler 3.1.9 Cluster with MySQL Instead of PostgreSQL? A Practical Docker Compose Guide"
}