大数跨境

MySQL元数据库Docker Compose部署Apache DolphinScheduler 3.1.9集群实战

MySQL元数据库Docker Compose部署Apache DolphinScheduler 3.1.9集群实战 海豚调度
2026-06-15
0
导读:本篇文章将为您揭秘,如何在官方方案的基础上进行巧妙调整,让您的DolphinScheduler集群成功跑在MySQL元数据库上。


点亮⭐️  

https://github.com/apache/dolphinscheduler



点击蓝字 关注我们



背景


今天我们将深入探讨一个备受关注的话题:如何使用 MySQL 元数据库,通过 Docker Compose 快速部署 Apache DolphinScheduler 3.1.9 集群。

大家都知道,DolphinScheduler 官方提供的 Docker Compose 部署方案默认使用的是 PostgreSQL 作为元数据存储。这主要是由于 MySQL 的 GPLv2 协议与 Apache License 2.0 之间存在不兼容性,导致官方无法直接提供基于 MySQL 的版本。然而,在实际生产环境中,很多团队更倾向于使用MySQL作为数据库,因为它在运维、工具支持和社区生态方面具有广泛的优势。

本篇文章将为您揭秘,如何在官方方案的基础上进行巧妙调整,让您的 DolphinScheduler 集群成功跑在 MySQL元数据库上。

下载镜像


docker pull apache/dolphinscheduler-master:3.1.9docker pull apache/dolphinscheduler-worker:3.1.9docker pull apache/dolphinscheduler-tools:3.1.9docker pull apache/dolphinscheduler-api:3.1.9docker pull apache/dolphinscheduler-alert-server:3.1.9docker pull bitnami/zookeeper:3.7.1

下载MySQL驱动


wget https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-j-8.0.33.zipunzip -q mysql-connector-j-8.0.33.zipcp mysql-connector-j-8.0.33/mysql-connector-j-8.0.33.jar .

准备镜像文件


Master、worker、api、alert-server使用的Dockerfile

# 基于DolphinScheduler官方镜像ARG SERVICE=apiFROM apache/dolphinscheduler-${SERVICE}:3.1.9# 将MySQL JDBC驱动拷贝到DolphinScheduler的lib目录# DolphinScheduler通常会从其lib目录加载JDBC驱动COPY mysql-connector-j-8.0.33.jar /opt/dolphinscheduler/libs/

tools使用的Dockerfile

# 基于DolphinScheduler官方镜像ARG SERVICE=toolsFROM apache/dolphinscheduler-${SERVICE}:3.1.9# 将MySQL JDBC驱动拷贝到DolphinScheduler的lib目录# DolphinScheduler通常会从其lib目录加载JDBC驱动COPY mysql-connector-j-8.0.33.jar /opt/dolphinscheduler/tools/lib/

编译新镜像


docker build --build-arg SERVICE=master -t apache/dolphinscheduler-master:3.1.9-mysql .docker build --build-arg SERVICE=worker -t apache/dolphinscheduler-worker:3.1.9-mysql .docker build --build-arg SERVICE=tools -t apache/dolphinscheduler-tools:3.1.9-mysql .docker build --build-arg SERVICE=api -t apache/dolphinscheduler-api:3.1.9-mysql .docker build --build-arg SERVICE=alert-server -t apache/dolphinscheduler-alert-server:3.1.9-mysql .

修改docker-compose.yaml


注释掉postgresql service,增加mysql service

# 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.services:#dolphinscheduler-postgresql:#  image: bitnami/postgresql:15.2.0#  ports:#    - "5432:5432"#  profiles: ["all", "schema"]#  environment:#    POSTGRESQL_USERNAME: root#    POSTGRESQL_PASSWORD: root#    POSTGRESQL_DATABASE: dolphinscheduler#  volumes:#    - dolphinscheduler-postgresql:/bitnami/postgresql#  healthcheck:#    test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/5432"]#    interval: 5s#    timeout: 60s#    retries: 120#  networks:#    - dolphinscheduler# MySQL 数据库服务 (元数据库)dolphinscheduler-mysql:image:mysql:8.0container_name:dolphinscheduler-mysqlprofiles: ["all""schema"]environment:MYSQL_ROOT_PASSWORD:${MYSQL_ROOT_PASSWORD:-root}MYSQL_DATABASE:${MYSQL_DATABASE:-dolphinscheduler}volumes:-dolphinscheduler-mysql:/var/lib/mysqlports:-"3306:3306"# 映射MySQL端口到宿主机,供其他服务器的Worker访问healthcheck:test: ["CMD""mysqladmin""ping""-h""localhost""-u""${MYSQL_USERNAME:-root}""-p${MYSQL_PASSWORD:-root}"# 健康检查,使用 .env 中的用户名密码interval:5stimeout:60sretries:120networks:-dolphinschedulerdolphinscheduler-zookeeper:image:bitnami/zookeeper:3.7.1profiles: ["all"]environment:ALLOW_ANONYMOUS_LOGIN:"yes"ZOO_4LW_COMMANDS_WHITELIST:srvr,ruok,wchs,consports:-"2181:2181"volumes:-dolphinscheduler-zookeeper:/bitnami/zookeeperhealthcheck:test: ["CMD""bash""-c""cat < /dev/null > /dev/tcp/127.0.0.1/2181"]interval:5stimeout:60sretries:120networks:-dolphinschedulerdolphinscheduler-schema-initializer:image:${HUB}/dolphinscheduler-tools:${TAG}env_file:.envprofiles: ["schema"]command: [ tools/bin/upgrade-schema.sh ]depends_on:dolphinscheduler-mysql:condition:service_healthyvolumes:-dolphinscheduler-logs:/opt/dolphinscheduler/logs-dolphinscheduler-shared-local:/opt/soft-/dolphinscheduler:/dolphinschedulernetworks:-dolphinschedulerdolphinscheduler-api:image:${HUB}/dolphinscheduler-api:${TAG}ports:-"12345:12345"-"25333:25333"profiles: ["all"]env_file:.envhealthcheck:test: [ "CMD""curl""http://localhost:12345/dolphinscheduler/actuator/health" ]interval:30stimeout:5sretries:3depends_on:dolphinscheduler-zookeeper:condition:service_healthyvolumes:-dolphinscheduler-logs:/opt/dolphinscheduler/logs-dolphinscheduler-shared-local:/opt/soft-/dolphinscheduler:/dolphinschedulernetworks:-dolphinschedulerdolphinscheduler-alert:image:${HUB}/dolphinscheduler-alert-server:${TAG}profiles: ["all"]env_file:.envhealthcheck:test: [ "CMD""curl""http://localhost:50053/actuator/health" ]interval:30stimeout:5sretries:3depends_on:dolphinscheduler-zookeeper:condition:service_healthyvolumes:-dolphinscheduler-logs:/opt/dolphinscheduler/logsnetworks:-dolphinschedulerdolphinscheduler-master:image:${HUB}/dolphinscheduler-master:${TAG}profiles: ["all"]env_file:.envenvironment:#增加java参数设置JAVA_OPTS:-server-Duser.timezone=${SPRING_JACKSON_TIME_ZONE}-Xms8g-Xmx8g-Xmn4g-XX:+PrintGCDetails-Xloggc:gc.loog-XX:+HeapDumpOnOutOfMemoryError-XX:HeapDumpPath=dump.hprofhealthcheck:test: [ "CMD""curl""http://localhost:5679/actuator/health" ]interval:30stimeout:5sretries:3depends_on:dolphinscheduler-zookeeper:condition:service_healthyvolumes:-dolphinscheduler-logs:/opt/dolphinscheduler/logs-dolphinscheduler-shared-local:/opt/softnetworks:-dolphinschedulerdolphinscheduler-worker:image:${HUB}/dolphinscheduler-worker:${TAG}profiles: ["all"]env_file:.envenvironment:JAVA_OPTS:-server-Duser.timezone=${SPRING_JACKSON_TIME_ZONE}-Xms8g-Xmx8g-Xmn4g-XX:+PrintGCDetails-Xloggc:gc.loog-XX:+HeapDumpOnOutOfMemoryError-XX:HeapDumpPath=dump.hprofhealthcheck:test: [ "CMD""curl""http://localhost:1235/actuator/health" ]interval:30stimeout:5sretries:3depends_on:dolphinscheduler-zookeeper:condition:service_healthyvolumes:-dolphinscheduler-worker-data:/tmp/dolphinscheduler-dolphinscheduler-logs:/opt/dolphinscheduler/logs-dolphinscheduler-shared-local:/opt/soft-/dolphinscheduler:/dolphinschedulernetworks:-dolphinschedulernetworks:dolphinscheduler:driver:bridgevolumes:#注释掉postgresql volume#dolphinscheduler-postgresql:dolphinscheduler-mysql:dolphinscheduler-zookeeper:dolphinscheduler-worker-data:dolphinscheduler-logs:dolphinscheduler-shared-local:

修改.env


# Docker Hub 镜像前缀和版本标签HUB=apacheTAG=3.1.9# MySQL 配置MYSQL_ROOT_PASSWORD=root # 替换为您希望的 MySQL root 密码MYSQL_DATABASE=dolphinscheduler # Dolphinscheduler 使用的数据库名称MYSQL_USERNAME=root # Dolphinscheduler 连接 MySQL 的用户名 (通常就是 root)MYSQL_PASSWORD=root # Dolphinscheduler 连接 MySQL 的密码 (与 root 密码相同)# Dolphinscheduler 数据库连接配置 (通过 Docker Compose 传递给 DS 服务)TZ=Asia/Shanghai#指定使用MySQL数据库DATABASE=mysqlSPRING_JACKSON_TIME_ZONE=GMT+8SPRING_DATASOURCE_URL=jdbc:mysql://dolphinscheduler-mysql:3306/${MYSQL_DATABASE}?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=trueSPRING_DATASOURCE_USERNAME=${MYSQL_USERNAME}SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD}REGISTRY_ZOOKEEPER_CONNECT_STRING=dolphinscheduler-zookeeper:2181MASTER_FETCH_COMMAND_NUM=10

初始化数据库


docker compose --profile schema up -d

启动集群


docker compose --profile all up -d

启动Worker服务


docker compose up -d dolphinscheduler-worker

启动Master服务


docker compose up -d dolphinscheduler-master

启动Alert服务


docker compose up -d olphinscheduler-alert

启动API服务


docker compose up -d dolphinscheduler-api

重启所有服务


docker compose --profile all restart

作者:学通
来源:https://juejin.cn/post/7527944272277667855





END






用户案例


DolphinScheduler Agent开源上线Cisco Webex天翼云Zoom网易邮箱 每日互动 惠生工程作业帮 博世智驾蔚来汽车 长城汽车集度长安汽车思科网讯食行生鲜联通医疗联想新网银行兴业证券唯品富邦消费金融 自如有赞伊利当贝大数据珍岛集团传智教育BigoYY直播  拈花云科太美医疗深圳某智能制造企业



迁移实战


Azkaban   Ooize(当贝迁移案例)Airflow (有赞迁移案例)Air2phin(迁移工具)Airflow



最新发版消息



Apache DolphinScheduler 3.4.2 正式发布!新增 Amazon EMR Serverless 插件,增强监控与补数据能力



加入社区


关注社区的方式有很多:

  • GitHub: https://github.com/apache/dolphinscheduler
  • 官网:https://dolphinscheduler.apache.org/en-us
  • 订阅开发者邮件:dev@dolphinscheduler@apache.org(向邮箱发送任意内容,收到邮件后回复同意订阅即可)
  • X.com:@DolphinSchedule
  • YouTube:https://www.youtube.com/@apachedolphinscheduler
  • Slack:https://join.slack.com/t/asf-dolphinscheduler/shared_invite/zt-1cmrxsio1-nJHxRJa44jfkrNL_Nsy9Qg

同样地,参与Apache DolphinScheduler 有非常多的参与贡献的方式,主要分为代码方式和非代码方式两种。

📂非代码方式包括:

完善文档、翻译文档;翻译技术性、实践性文章;投稿实践性、原理性文章;成为布道师;社区管理、答疑;会议分享;测试反馈;用户反馈等。

👩‍💻代码方式包括:

查找Bug;编写修复代码;开发新功能;提交代码贡献;参与代码审查等。

贡献第一个PR(文档、代码) 我们也希望是简单的,第一个PR用于熟悉提交的流程和社区协作以及感受社区的友好度。

社区汇总了以下适合新手的问题列表https://github.com/apache/dolphinscheduler/pulls?q=is%3Apr+is%3Aopen+label%3A%22first+time+contributor%22

优先级问题列表https://github.com/apache/dolphinscheduler/pulls?q=is%3Apr+is%3Aopen+label%3Apriority%3Ahigh

如何参与贡献链接https://dolphinscheduler.apache.org/zh-cn/docs/3.2.2/%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97_menu/%E5%A6%82%E4%BD%95%E5%8F%82%E4%B8%8E_menu

如果你❤️小海豚,就来为我点亮Star吧!

https://github.com/apache/dolphinscheduler



你的好友小海豚拍了拍你

并请你帮她点一下“分享”


【声明】内容源于网络
0
0
海豚调度
Apache DolphinScheduler是一个分布式、去中心化、易扩展的可视化DAG工作流任务调度系统,其致力于解决数据处理流程中错综复杂的依赖关系,使调度系统在数据处理流程中开箱即用。
内容 0
粉丝 0
海豚调度 Apache DolphinScheduler是一个分布式、去中心化、易扩展的可视化DAG工作流任务调度系统,其致力于解决数据处理流程中错综复杂的依赖关系,使调度系统在数据处理流程中开箱即用。
总阅读0
粉丝0
内容0