暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

DolphinScheduler 6 个高频 SQL 操作技巧

海豚调度 2025-07-01
141

点击蓝字,关注我们

摘要: Apache DolphinScheduler系列4-后台SQL经验分享

关键词: 大数据、数据质量、数据调度

整体说明

在调研了 DolphinScheduler 之后,在项目上实际使用了一段时间,有了一些后台SQL实际经验,分享如下。

  • 进入DolphinScheduler 后台数据库,我这里使用的是MySQL数据库。
  • 以任务名称包含“ods_xf_act” 的任务为例。

一、修改任务组操作

UPDATE t_ds_task_definition a
join t_ds_task_definition_log b on a.`code`=b.`code`and a.version=b.version
set a.task_group_id = 19,b.task_group_id=19
where a.name like'%ods_xf_act%'

二、批量修改任务执行类型

UPDATE t_ds_process_definition a
join t_ds_process_definition_log b on a.code=b.code and a.version=b.version
set a.execution_type = 1,b.execution_type=1
where a.name like'%ods_xf_act%'

三、查看定时器配置情况

根据此来选择配置定时器

select crontab,count(*) from t_ds_schedules
groupby crontab
orderbycount(*) desc

四、批量更改定时器

定时器,在前台页面修改很麻烦,一个个改很慢,所以想着从后台批量修改。

  1. 确定需要更新的定时器列表
select t1.id,t1.process_definition_code,crontab,t2.name from t_ds_schedules t1
join t_ds_process_definition t2
on t1.process_definition_code = t2.`code`
wherenamelike'%ods_xf_act%'
and crontab like'%0 0 5 *%'

2. 更新成需要的crontab定时器
update t_ds_schedules t1
join t_ds_process_definition t2
on t1.process_definition_code = t2.`code`
set t1.crontab = '0 0 11 * * ? *'
wherenamelike'%ods_xf_act%'
and crontab like'%0 0 5 *%'

3. 更新成需要的crontab定时器触发表 由于定时器已经 5 -> 11修改完成, 所以后面的where 条件都是 11
update qrtz_cron_triggers t1
set t1.CRON_EXPRESSION = '0 0 11 * * ? *'
where t1.TRIGGER_NAME in (
selectconcat("job_",t1.id) from t_ds_schedules t1
join t_ds_process_definition t2
on t1.process_definition_code = t2.`code`
wherenamelike'%ods_xf_act%'
and crontab like'%0 0 11 *%'
)

4. 更新成最新crontab定时触发时间的起始时间 由于NEXT_FIRE_TIME有更新时差,所以往前推8小时
update qrtz_triggers t1
set t1.NEXT_FIRE_TIME = round(UNIX_TIMESTAMP(date_sub("2024-07-23 11:00:00"INTERVAL8HOUR) )*1000)
where t1.TRIGGER_NAME in (
selectconcat("job_",t1.id) from t_ds_schedules t1
join t_ds_process_definition t2
on t1.process_definition_code = t2.`code`
wherenamelike'%ods_xf_act%'
and crontab like'%0 0 11 *%'
)

五、通知策略修改为“都不发”,仍然告警

现象: 原先选择“失败发”,后面修改为“都不发”

原因: 原先有告警组,然后修改为都不发,原告警组后台并没有修改,是一个bug。

临时解决方案:

select t1.*
from t_ds_schedules t1
join t_ds_process_definition t2
on t1.process_definition_code = t2.`code`
wherenamelike'%ods_xf_act%'

把warning_type = 0 的,对应warning_group_id 都修改为 0

六、任务组队列,页面没有任务,已用资源却占满

查看任务组列表

select * from t_ds_task_group
orderby create_time desc

-- 如果遇到任务组是满的,页面查询却没有任务,可以手动修改字段值

查看任务组队列列表,找出没有完成,修改成已完成,就是修改值为2。

-- t_ds_task_group_queue.`status` tinyint(4) DEFAULT '-1' COMMENT '-1: waiting  1: running  2: finished'

select * from t_ds_task_group_queue
where1=1
andstatus <> 2  -- finished 完成
orderby create_time desc

查看任务列表,找出没有完成,修改成已完成,就是修改值为7。

-- t_ds_task_instance.`state` tinyint(4) DEFAULT NULL COMMENT 'Status: 0 commit succeeded, 1 running, 2 prepare to pause, 3 pause, 4 prepare to stop, 5 stop, 6 fail, 7 succeed, 8 need fault tolerance, 9 kill, 10 wait for thread, 11 wait for dependency to complete'

-- id 是上面t_ds_task_group_queue的task_id

select * from t_ds_task_instance
where state <> 7-- success
andidin (
selectidfrom t_ds_task_group_queue
where1=1
andstatus <> 2-- finished 完成
orderby create_time desc
)
orderby submit_time desc
limit100

转载自鹏说大数据

原文链接:Apache DolphinScheduler系列4-后台SQL经验分享





用户案例



网易邮箱 每日互动 惠生工程  作业帮 
博世智驾 蔚来汽车 长城汽车集度长安汽车
思科网讯食行生鲜联通医疗联想
新网银行唯品富邦消费金融 
自如有赞伊利当贝大数据
珍岛集团传智教育Bigo
YY直播  三合一太美医疗
Cisco Webex兴业证券




迁移实战



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



发版消息




Apache DolphinScheduler 3.2.2版本正式发布!
Apache DolphinScheduler 3.2.1 版本发布:增强功能与安全性的全面升级
Apache DolphinScheduler 3.3.0 Alpha发布,功能增强与性能优化大升级!




加入社区



关注社区的方式有很多:

  • 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


你的好友秀秀子拍了拍你

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

文章转载自海豚调度,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论