DolphinScheduler配置详解:系统参数配置指南
概述
DolphinScheduler作为一款强大的分布式工作流任务调度系统,其配置体系的灵活性和完整性直接决定了系统的稳定性和性能表现。本文将深入解析DolphinScheduler的核心配置参数,帮助您全面掌握系统配置技巧。
核心配置文件结构
DolphinScheduler采用模块化配置设计,主要配置文件分布在各个组件的src/main/resources目录下:
数据库配置详解
多数据库支持配置
DolphinScheduler支持PostgreSQL和MySQL两种数据库,通过Spring Profiles实现配置切换:
# 默认使用PostgreSQL
spring:
profiles:
active: postgresql
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://127.0.0.1:5432/dolphinscheduler
username: root
password: root
hikari:
connection-test-query: select 1
pool-name: DolphinScheduler
# MySQL配置(通过profile激活)
---
spring:
config:
activate:
on-profile: mysql
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/dolphinscheduler
username: root
password: root
数据库连接池关键参数
| 参数名称 | 默认值 | 说明 | 推荐配置 |
|---|---|---|---|
| connection-test-query | select 1 | 连接测试SQL | 保持默认 |
| pool-name | DolphinScheduler | 连接池名称 | 根据环境区分 |
| maximum-pool-size | 10 | 最大连接数 | 根据并发量调整 |
| minimum-idle | 5 | 最小空闲连接 | 生产环境建议10 |
服务器配置参数
API服务器配置
server:
port: 12345
servlet:
session:
timeout: 120m
context-path: /dolphinscheduler/
compression:
enabled: true
mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json,application/xml
jetty:
max-http-form-post-size: 5000000
Master服务器配置
server:
port: 5679
master:
listen-port: 5678
max-heartbeat-interval: 10s
worker-group-refresh-interval: 5m
注册中心配置
DolphinScheduler支持多种注册中心,默认使用ZooKeeper:
registry:
type: zookeeper
zookeeper:
namespace: dolphinscheduler
connect-string: localhost:2181
retry-policy:
base-sleep-time: 1s
max-sleep: 3s
max-retries: 5
session-timeout: 60s
connection-timeout: 15s
ZooKeeper配置参数说明
| 参数 | 默认值 | 说明 | 调优建议 |
|---|---|---|---|
| base-sleep-time | 1s | 重试基础等待时间 | 生产环境可适当增加 |
| max-sleep | 3s | 最大重试等待时间 | 根据网络状况调整 |
| max-retries | 5 | 最大重试次数 | 建议8-10次 |
| session-timeout | 60s | 会话超时时间 | 根据集群规模调整 |
安全认证配置
多认证方式支持
security:
authentication:
type: PASSWORD # 支持PASSWORD,LDAP,CASDOOR_SSO
# LDAP认证配置
ldap:
url: ldap://ldap.forumsys.com:389/
base-dn: dc=example,dc=com
username: cn=admin,dc=example,dc=com
password: password
# OAuth2认证配置
oauth2:
enable: false
provider:
github:
authorizationUri: ""
clientId: ""
clientSecret: ""
任务调度配置
Quartz调度器配置
spring:
quartz:
job-store-type: jdbc
properties:
org.quartz.jobStore.isClustered: true
org.quartz.scheduler.instanceId: AUTO
org.quartz.jobStore.tablePrefix: QRTZ_
org.quartz.threadPool.threadCount: 25
org.quartz.jobStore.misfireThreshold: 60000
工作流事件总线配置
master:
# 工作流事件总线触发线程数,默认2*CPU核心数+1
workflow-event-bus-fire-thread-count: 10
# 逻辑任务执行线程数
logic-task-config:
task-executor-thread-count: 10
系统监控与度量
健康检查配置
management:
endpoints:
web:
exposure:
include: health,metrics,prometheus
endpoint:
health:
enabled: true
show-details: always
health:
db:
enabled: true
性能度量配置
metrics:
enabled: true
tags:
application: ${spring.application.name}
流量控制配置
api:
traffic-control:
global-switch: false
max-global-qps-rate: 300
tenant-switch: false
default-tenant-qps-rate: 10
# 自定义租户QPS配置
# tenant1: 11
# tenant2: 20
负载保护机制
Master服务器负载保护
master:
server-load-protection:
enabled: true
max-system-cpu-usage-percentage-thresholds: 0.7
max-jvm-cpu-usage-percentage-thresholds: 0.7
max-system-memory-usage-percentage-thresholds: 0.7
max-disk-usage-percentage-thresholds: 0.7
Worker负载均衡策略
master:
worker-load-balancer-configuration-properties:
type: DYNAMIC_WEIGHTED_ROUND_ROBIN
dynamic-weight-config-properties:
memory-usage-weight: 30
cpu-usage-weight: 30
task-thread-pool-usage-weight: 40
环境特定配置最佳实践
开发环境配置
# application-dev.yaml
spring:
datasource:
url: jdbc:postgresql://localhost:5432/ds_dev
username: dev_user
password: dev_password
server:
port: 12346
生产环境配置
# application-prod.yaml
spring:
datasource:
url: jdbc:postgresql://prod-db:5432/ds_prod
username: prod_user
password: ${DB_PASSWORD}
hikari:
maximum-pool-size: 20
minimum-idle: 10
registry:
zookeeper:
connect-string: zk1:2181,zk2:2181,zk3:2181
max-retries: 10
配置管理建议
1. 敏感信息管理
- 使用环境变量注入密码等敏感信息
- 避免在配置文件中硬编码敏感数据
2. 配置版本控制
- 将配置文件纳入版本控制系统
- 为不同环境维护独立的配置文件
3. 监控与告警
- 监控配置变更情况
- 设置配置异常告警机制
4. 定期审计
- 定期审查配置安全性
- 清理不再使用的配置项
常见配置问题排查
| 问题现象 | 可能原因 | 解决方案 |
|---|---|---|
| 数据库连接失败 | 连接字符串错误 | 检查数据库URL格式 |
| ZooKeeper连接超时 | 网络问题或配置错误 | 验证connect-string配置 |
| 调度任务不执行 | Quartz配置错误 | 检查表前缀和集群配置 |
| 认证失败 | 安全配置错误 | 验证认证类型和参数 |
通过本文的详细解析,您应该能够全面掌握DolphinScheduler的配置体系。合理的配置是系统稳定运行的基础,建议根据实际业务需求和环境特点进行针对性调优。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考



