大数据调度器--单机版Apache DolphinScheduler 入门到实践:进阶
在现代数据处理和工作流管理中,Apache DolphinScheduler 以其强大的调度能力和易用性,成为了许多企业和开发者的首选工具。https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105555265-897079430.png
本文将深入探讨 DolphinScheduler 的进阶使用技巧,包罗参数通报、资源中央管理、告警通知配置,以及怎样在真实项目中高效使用 DolphinScheduler。
进阶使用
参数通报
参数通报是 DolphinScheduler 中的一项重要功能,它允许用户在任务之间共享数据。
[*]局部变量:仅在单个使掷中有用,适用于特定任务的独立配置。
[*]全局变量:在多个任务间共享,恰当跨任务通报日期、配置等通用信息。
局部变量-只针对单个任务
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105555890-597987815.png
将工作流上线,执行,查看A的日志,发现打印了。
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105556746-149322142.png
全局变量-多个使掷中都需要一个字段
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105557107-1417505544.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105557551-1059820029.png
现在 A\B\C 任务都需要一个变量 dt。
在保存工作流的时候,弹出来的界面可以指定全局变量。
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105557934-1082630803.png
执行效果:
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105558359-866563620.png
)
B和C都是打印的2023-7-20,唯独A打印的是2023-7-18
因为A设置了局部变量,当一个任务有局部变量又有全局变量的时候,以局部变量的值为准(就近原则)
日期
Linux中获取前一天数据的命令:date -d '1 day ago' +'%y%m%d'
date1=`date -d '1 day ago' +'%y%m%d'`Apache DolphinScheduler提供了一些时间相干的系统参数,方便定时调度使用。
系统参数
格式太固定,没法自界说
参数说明$定时时间前一天,格式为yyyyMMdd$定时时间,格式为yyyyMMdd$定时时间,格式为yyyyMMddHHmmss实战
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105558705-1865619443.png
查看B的日志:
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105559111-350235435.png
自界说时间
参数说明$后N 年$前N 年$后N 月$前N 月$后N 周$前N 周$后N 天$前N 天$后N 小时$前N 小时$后N 分钟$前N 分钟在C使掷中
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105559450-1925121503.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105559834-724844132.png
自界说日期格式
$, $, $
$也可以写成$
$ 也可以添加: $https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105600237-1704770948.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105600626-170176418.png
资源中央
资源中央是 DolphinScheduler 的文件管理平台,支持用户上传和管理资源文件。
[*]资源上传:用户可以将脚本、数据文件等上传到资源中央,方便在使掷中引用。
[*]资源使用:在任务配置中直接引用资源中央的文件,提高资源复用性和管理服从。
资源上传
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105601137-88654331.png
保存之后其实本质上是上传到了HDFS路径下。
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105601599-196797679.png
资源使用
资源怎样使用?
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105602051-124320132.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105602296-1426115620.png
告警通知
告警通知是确保任务状态及时反馈给用户的重要机制。
DS是一个任务调度工具,当任务执行很慢的时候,我们需要一个告警通知,不管是成功还是失败,都需要第一时间收到通知。
[*]邮件告警:配置邮件服务器,任务执行完成后发送邮件通知,适用于任务状态报告和非常通知。
[*]SMS 告警:发送短信通知,适用于紧急情况的通知,但留意大概存在功能限制或 Bug。
邮件告警
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105602709-1042347362.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105603219-516498643.png
在任务流运行时,指定告警者组:
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105603811-1178079775.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105604400-1472412901.png
以下是 DS 1.x 版本进行邮箱告警的配置:
需要一个可以或许发送邮件的邮箱(这个邮箱是一个发送方,需要将信息发送给需要的人)
vi /opt/installs/dolphinscheduler/conf/alert.properties
不要修改/opt/modules下的dolphinscheduler,这个文件夹下的内容在你安装完之后的那一刻已经没有任何价值了。修改邮箱服务器的配置:
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105604939-1727794526.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105605375-1520529045.png
修改alert.properties中的文件:
# mail server configuration
mail.protocol=SMTP
mail.server.host=smtp.163.com
mail.server.port=25
mail.sender=18638147931@163.com
mail.user=18638147931@163.com
mail.passwd=MAGBDQDGKEHCBVQA
# TLS
mail.smtp.starttls.enable=false
# SSL
mail.smtp.ssl.enable=false
mail.smtp.ssl.trust=smtp.exmail.qq.com重启Alert服务:
./bin/dolphinscheduler-daemon.sh start alert-server
./bin/dolphinscheduler-daemon.sh stop alert-server验证是否可用:
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105605769-967430793.png
记得同步一下时间。假如需要你做一个电话通知,怎么办?因为平台是默认不支持电话的。
使用第三方平台 -- 睿象云
只需要获取一个睿象云的邮箱即可得到电话通知。
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105606301-966233239.png
工作流重跑
当一个工作流特长,任务特殊复杂的时候,执行到某一处失败了,下一次想从失败的地方开始运行,而不是重新开始。
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105606748-1647190824.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105607273-2041150010.png
修改任务,将失败的地方修复一下,开始运行。
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105607572-840562571.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105608026-2050479418.png
[*]重跑:从头开始,再来一遍
[*]恢复失败:从失败的节点开始运行,直到运行结束。
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105608373-346818158.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105608789-799761269.png
https://img2024.cnblogs.com/other/2685289/202410/2685289-20241016105609196-477319030.png
关闭 Linux 中的提醒
在 Linux 系统中,有时候需要关闭邮件提醒,可以通过以下命令实现:
cat /dev/null > /var/spool/mail/root
echo "unset MAILCHECK" >> /etc/profile
source /etc/profile总结
Apache DolphinScheduler 提供了丰富的功能和灵活的配置选项,使其成为处理复杂工作流和数据管道的理想工具。
无论是在参数通报、资源管理,还是在告警通知和项目自动化方面,DolphinScheduler 都能提供强大的支持。通过本文的介绍,希望能帮助您更深入地理解 DolphinScheduler 的使用,以及怎样在现实项目中高效地应用它。
本文来源于网络,原文链接:https://blog.csdn.net/weixin_64726356/article/details/142160565
本文由 白鲸开源 提供发布支持!
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]