thales是一款自主研发的分布式任务调度系统,系统支持command,shell,hive,spark,python,http,sql,flink,clickhouse等任务类型。实测每天可调度百万次任务,满足市场上90%以上公司调度需求。
- 动态任务依赖
- 可定义复杂的任务依赖关系
- 分布式部署
- 基于真实资源
- 资源隔离,相同类型的任务可以提交到对应的资源池
- 支持大规模任务调度
- 节点掉线自动发现
- 任务失败后自动重试
- 任务失败或超时告警
- 提供HA
- 可以通过页面调度,停止,查看任务详情和依赖等等
- 可以调度hive,spark,flink等大数据任务
- 提供各种图表方便用户查看任务执行情况
- 提供数据源管理
- 提供参数管理
- thales-scheduler
- scheduler-alert --任务告警
- scheduler-api --对外接口
- scheduler-controller --任务控制层
- scheduler-dao --任务数据层
- scheduler-service --任务服务层
- scheduler-common --通用帮助类
- scheduler-master --任务调度
- quartz --任务调度
- master manager --任务资源管理
- task status management --任务状态管理
- rpc client --提交任务
- scheduler-worker --任务执行
- rpc server --接收任务请求
- log --日志服务器
- executor-- 任务执行器
- scheduler-core --核心实现
- scheduler-model --对外服务接口模型
- sql --系统使用表ddl
api作为接口层,主要有如下功能:
- 和前端交互,负责任务调度,下线,重跑,看日志等。
master作为调度的核心,主要有如下功能:
- 初始化任务实例状态
- 通过quartz调度所有任务
- 检查任务状态
- 启动master rpc服务供worker汇报资源和心跳
- master ha
- 启动jetty server接受api的调用
- 根据机器cpu,内存,任务负载个数等选择最优的worker调度
- 节点的上线与下线管理
worker作为执行器,主要有如下功能:
- 负责任务的执行,目前可执行shell,hive,spark等任务
- 启动jetty server供查看任务日志,
- 上报资源信息,发送心跳给master.
alert主要提供告警功能:
- 任务失败时告警。
- 任务超时告警。
- 目前只支持email.
- git clone https://github.com/ylpu/distribute-job-scheduler.git ,将项目导入到intellij或eclipse中并安装lombok.
- 本地安装mysql,zookeeper,如非本地安装,需要修改controller,master,worker config目录里config.properties,application.yml文件的zookeeper和mysql地址和端口
- 在mysql数据库中执行语句
- distribute-job-scheduler/thales-scheduler/sql/thales-scheduler.sql
- insert into t_thales_scheduler_user(user_name,password,create_time,update_time) values ('test','test',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
- insert into t_thales_scheduler_role(role_name,create_time,update_time) values ('ROLE_ADMIN',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);
- insert into t_thales_scheduler_user_role(user_id,role_id,create_time,update_time) values ($user_id,$role_id,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);(其中$user_id,$role_id为上面插入语句的相应id)
- 在distribute-job-scheduler中执行mvn clean install -Dmaven.test.skip=true
- 依次执行如下脚本
- scheduler-api/bin/api-server.sh start ,启动成功后可以通过http://localhost:8085/swagger-ui.html 查看接口文档
- scheduler-master/bin/master-server.sh start,启动成功后可以通过 http://localhost:9095/ 查看master jmx信息
- scheduler-worker/bin/worker-server.sh start,启动后可以通过查看10001端口判断logserver是否成功(启动worker前确保通过页面执行组管理添加相应的执行器组)
- 运行distribute-job-scheduler-frontend(https://github.com/ylpu/distribute-job-scheduler-frontend) 项目并以如上用户名,密码登陆
- 创建任务(创建任务后点击调度)
- 任务名称 : 任务名称,必须唯一
- 任务工作组: 任务会被提交到相应的组里
- 任务依赖: 选择需要依赖的任务
- 任务优先级: 任务的优先度,有低,中,高三种
- 任务责任人:任务的所属人
- 任务类型:目前command,shell,hive,spark,flink,clickhouse,http,sql,python 9种。
- 任务告警人: 任务失败,超时的时候需要通知的人(邮箱格式)
- 告警类型:有sms,webchat,email三种,目前只支持emai(请在thales-scheduler/scheduler-alert/src/main/resources/email.properties配置相应的邮件服务器信息)。
- 调度时间:cron表达式
- 任务周期:分钟,小时,天,周,月,年等
- 重试次数:任务失败时最多重试的次数
- 超时时间:超过多少分钟任务将会被杀死。
- 任务描述:任务的详细信息
- 任务配置:根据类型不同有不同的配置(以下为简单例子):
- command: {"command" :"pwd;cat /tmp/log/scheduler-worker/info.log","parameters" : {"param1":"test"}}
- shell: {"fileName" : "/tmp/shell/test.sh","parameters" : {"param1":"test"}}
- python: {"fileName" : "/tmp/python/test.py","parameters" : {"param1":"test"}}
- hive: {"fileName" : "/tmp/shell/test.hql","config" : "","parameters":{"dt":"20191205","hm":"1000"}
- spark: {"fileName":"/tmp/shell/test.sql","config":{"masterUrl":"spark://localhost:7077","executorMemory":"2g","executorCores":2,"totalExecutorCores":20},"parameters":{"dt":"20191205","hm":"1000"}
- http:
- get:{"url":"http://localhost:8085/api/job/getJobById", "method": "get", "parameters":{ "id":45 } }
- post:{"url":"http://localhost:8085/api/job/addJob", "method": "post", "parameters":{ "alertTypes": "email", "alertUsers": "string", "creatorId": "string", "dependIds": [], "description": "string", "executionTimeout": 0, "isSelfdependent": true, "jobConfiguration": "string", "jobCycle": "DAY", "jobName": "rest-test", "jobPriority": "HIGH", "jobReleasestate": 0, "jobType": "shell", "maxRetrytimes": 0, "ownerIds": "test", "retryInterval": 0, "scheduleCron": "0 3 15 * * ?", "workerGroupname": "hive" } }
- sql : { "dsName":"mysql-test(连接管理里的连接名称)", "operator":"select", "sql":"select * from t_thales_scheduler_job_instance where id = ?", "parameters":{"param1":76} }
- flink : { "className":"", "jarName":"", "config": {"mode":"","slotNumber":2,"applicationName":"","taskManagerNumber":2,"taskManagerMemory":"2g","jobManagerMemory":"2g"} }
- clickhouse : { "dsName":"ck-test(连接管理里的连接名称)", "query":"select * from t_thales_scheduler_job_instance where id = ?", "config":{"sendTimeout":10000,"receiveTimeout":10000}, "parameters":{"dt":"20191205","hm":"1000"} }
- 修改任务
- 参数与创建任务相同(修改后需要点击重新调度)
- 任务图
- 查看整个任务的依赖关系
- 实例图
- 图表方式查看任务近30天的运行情况