
点亮⭐️
https://github.com/apache/
点击蓝字 关注我们
本文面向希望在本地阅读和调试 DolphinScheduler 核心源码的开发者,示例环境为 Windows + IntelliJ IDEA + Docker Desktop + PostgreSQL + ZooKeeper。
如果你只是想快速体验功能,而不是调试 master / worker / api 的完整链路,优先使用 StandaloneServer。如果你希望调试分布式调度主链路,再按本文使用拆分服务方式启动。
适用场景
MasterServer、WorkerServer、ApiApplicationServer环境要求
mvnw.cmd当前仓库根
pom.xml中的java.version为1.8,本地调试建议优先使用 JDK 8 或 11。
启动PostgreSQL和ZooKeeper
先进入 deploy/docker 目录。
cd 某盘:\dolphinscheduler\deploy\docker
如果你直接使用附录里的 docker-compose-windows.yml,需要先确认 dolphinscheduler-zookeeper 是否暴露了 2181 端口。master、worker、api 都默认连接 localhost:2181,如果 ZooKeeper 只运行在容器内而没有映射到宿主机,IDEA 中启动的 Java 进程会连接失败。
请确保 docker-compose-windows.yml的dolphinscheduler-zookeeper 服务包含如下配置:
dolphinscheduler-zookeeper: image: zookeeper:3.8 ports: - "2181:2181"
然后启动 PostgreSQL 和 ZooKeeper:
docker-compose -f docker-compose-windows.yml up -d dolphinscheduler-postgresql dolphinscheduler-zookeeper
可选验证命令:
docker psTest-NetConnection 127.0.0.1 -Port 5432Test-NetConnection localhost -Port 2181
预期结果:
5432
2181
如果你使用的是本机或远程服务器上安装的 PostgreSQL 或 ZooKeeper,而不是 Docker,可以跳过这一步,但要确保后续配置中的地址、端口、用户名和密码与你本机环境一致。
编译项目
在仓库根目录执行:
cd 某盘:\dolphinscheduler.\mvnw.cmd spotless:apply.\mvnw.cmd clean install -DskipTests
说明:
spotless:apply
初始化PostgreSQL元数据库
master 和 api 启动前,DolphinScheduler 的元数据库表必须先初始化。当前仓库的 PostgreSQL 初始化脚本位于:
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
也就是:
某盘:\dolphinscheduler\dolphinscheduler-dao\src\main\resources\sql\dolphinscheduler_postgresql.sql
如果你使用的是 Docker 里的 PostgreSQL,可以直接在 PowerShell 中执行:
Get-Content -Path .\dolphinscheduler-dao\src\main\resources\sql\dolphinscheduler_postgresql.sql -Raw | docker exec -i -e PGPASSWORD=root docker-dolphinscheduler-postgresql-1 psql -U root -d dolphinscheduler
也可以使用 DataGrip、DBeaver 或 psql 手动执行整份 SQL 文件。
注意:这份 SQL 包含
DROP TABLE IF EXISTS,会重建元数据库表。请不要在已有重要数据的数据库上直接执行。
初始化完成后,可以执行以下 SQL 验证:
select version from t_ds_version;
预期结果是返回一条版本记录,例如 3.4.0。
核对本地配置
当前仓库默认已经使用 PostgreSQL 和 ZooKeeper,本地如果采用以下默认值,通常不需要额外改配置:
127.0.0.1:5432dolphinschedulerrootrootlocalhost:2181相关配置文件:
dolphinscheduler-master/src/main/resources/application.yaml
dolphinscheduler-api/src/main/resources/application.yaml
dolphinscheduler-worker/src/main/resources/application.yaml
如果你的本地依赖不是以上默认值,再修改这些配置项:
spring.datasource.url
spring.datasource.username
spring.datasource.password
registry.zookeeper.connect-string
如果你使用 PostgreSQL,不要在 IDEA 的 VM Options 中继续带 -Dspring.profiles.active=mysql。如果你需要显式指定 profile,请使用:
-Dspring.profiles.active=postgresql
配置IntelliJ IDEA启动项
每个启动项都建议统一配置如下:
Use classpath of module
Add dependencies with "provided" scope to classpathWorking directory
Add dependencies with "provided" scope to classpath很关键,不勾选时,启动阶段容易出现类找不到或依赖缺失问题。
建议创建以下三个启动项:
org.apache.dolphinscheduler.server.master.MasterServerdolphinscheduler-master默认监听端口:
56785679org.apache.dolphinscheduler.server.worker.WorkerServerdolphinscheduler-worker默认监听端口:
12341235org.apache.dolphinscheduler.api.ApiApplicationServerdolphinscheduler-api默认监听端口:
1234525333启动顺序建议如下:
MasterServer
WorkerServer
ApiApplicationServer
AlertServer 可以按需启动。只有当你需要调试告警链路时,再单独启动它。
启动前端
在仓库根目录执行:
cd 某盘:\dolphinscheduler\dolphinscheduler-uipnpm installpnpm run dev
启动完成后,前端默认访问地址为:
http://localhost:5173
默认账号密码:
admindolphinscheduler123启动成功后的验证方式
浏览器访问:
http://localhost:12345/dolphinscheduler/actuator/health
http://localhost:12345/dolphinscheduler/swagger-ui/index.html
预期结果:
actuator/health
UPswagger-ui
浏览器访问:
http://localhost:5173
能够正常打开登录页并完成登录,说明前后端联调基本打通。
在 IDEA 中则重点观察各服务控制台输出是否出现致命异常。
常见问题
MasterServer 启动失败,日志提示 zookeeper connect failed to: localhost:2181原因通常有两个:
2181暴露到宿主机排查方式:
Test-NetConnection localhost -Port 2181
如果连接失败,优先检查 docker-compose-windows.yml 中是否为 dolphinscheduler-zookeeper 配置了:
ports:
- "2181:2181"
ApiApplicationServer 启动失败,日志提示 relation "t_ds_version" does not exist这说明 PostgreSQL 元数据库还没有初始化,或者初始化到了错误的数据库。
处理方式:
dolphinscheduler_postgresql.sqldolphinscheduler 数据库select version from t_ds_version; 验证表是否存在优先检查是否勾选了:
Add dependencies with "provided" scope to classpath
如果没有勾选,这类问题会非常常见。
api 时端口 12345 被占用排查方式:
Test-NetConnection localhost -Port 12345
如果已经有进程占用该端口,请先停止原有进程,再重新启动 IDEA 中的 ApiApplicationServer。
附录
Docker-compose-windows
# 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.version: "3.8"services: dolphinscheduler-postgresql: image: bitnami/postgresql:latest ports: - "5432:5432" 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 dolphinscheduler-zookeeper: image: zookeeper:3.8 ports: - "2181:2181" environment: ALLOW_ANONYMOUS_LOGIN: "yes" ZOO_4LW_COMMANDS_WHITELIST: srvr,ruok,wchs,cons volumes: - dolphinscheduler-zookeeper:/bitnami/zookeeper healthcheck: test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/2181"] interval: 5s timeout: 60s retries: 120 networks: - dolphinschedulernetworks: dolphinscheduler: driver: bridgevolumes: dolphinscheduler-postgresql: dolphinscheduler-zookeeper:
END

用户案例

迁移实战

最新发版消息

加入社区
关注社区的方式有很多:
同样地,参与Apache DolphinScheduler 有非常多的参与贡献的方式,主要分为代码方式和非代码方式两种。
非代码方式包括:
完善文档、翻译文档;翻译技术性、实践性文章;投稿实践性、原理性文章;成为布道师;社区管理、答疑;会议分享;测试反馈;用户反馈等。
代码方式包括:
查找Bug;编写修复代码;开发新功能;提交代码贡献;参与代码审查等。


你的好友秀秀子拍了拍你
并请你帮她点一下“分享”
