一、实现功能
定时任务执行。
二、步骤
1.配置统一系统时区
(1)确认东八区
date -R
(2)不是的话修改,并且重启系统
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
2.修改oozie-site.xml
(1)添加
<property>
<name>oozie.processing.timezone</name>
<value>GMT+0800</value>
</property>
(2)修改参数
<property>
<name>oozie.service.coord.check.maximum.frequency</name>
<value>false</value>
<description>
When true, Oozie will reject any coordinators with a frequency faster than 5 minutes. It is not recommended to disable
this check or submit coordinators with frequencies faster than 5 minutes: doing so can cause unintended behavior and
additional system stress.
</description>
</property>
3.修改js文件
vi oozie-server/webapps/oozie/oozie-console.js
修改时区
function getTimeZone() {
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
return Ext.state.Manager.get("TimezoneId","GMT+0800");
}
4.重启oozie服务
bin/oozied.sh stop
bin/oozied.sh start
5.使用coordinator调度
(1)复制cron模板
cp -r examples/apps/cron oozie-apps/
(2)修改job.properties
nameNode=hdfs://hadoop:8020
jobTracker=hadoop:8032
queueName=default
examplesRoot=oozie-apps
oozie.coord.application.path=${nameNode}/user/hadoop/${examplesRoot}/cron
start=2018-07-01T11:05+0800 //按照东8区自动开始时间
end=2018-07-01T11:10+0800 //按照东8区自动结束时间
workflowAppUri=${nameNode}/user/hadoop/${examplesRoot}/shell //workflow目录,调动上面的shell
EXEC=mem.sh
(3)修改workflow.xml
<start to="shell-node"/>
<action name="shell-node">
<shell xmlns="uri:oozie:shell-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>${EXEC}</exec>
<file>${nameNode}/user/hadoop/${examplesRoot}/shell/${EXEC}#${EXEC}</file>
</shell>
<ok to="end"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Shell action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
(4)修改coordinator.xml
<coordinator-app name="cron-coord" frequency="${coord:minutes(1)}" start="${start}" end="${end}" timezone="GMT+0800"
xmlns="uri:oozie:coordinator:0.2">
<action>
<workflow>
<app-path>${workflowAppUri}</app-path>
<configuration>
<property>
<name>jobTracker</name>
<value>${jobTracker}</value>
</property>
<property>
<name>nameNode</name>
<value>${nameNode}</value>
</property>
<property>
<name>queueName</name>
<value>${queueName}</value>
</property>
</configuration>
</workflow>
</action>
</coordinator-app>
6.上传hdfs
bin/hdfs dfs -put /opt/modules/oozie-4.1.0-cdh5.7.0/oozie-apps/cron/ /user/hadoop/oozie-apps/
7.提交coordinator脚本任务
bin/oozie job -oozie http://hadoop:11000/oozie -config oozie-apps/cron/job.properties -run
8.杀掉job
bin/oozie job -oozie http://hadoop:11000/oozie -kill 0000000-181206232453659-oozie-root-C