Oozie bundle定时调度多job

本文介绍了如何利用Oozie Bundle来实现多Job的定时调度。通过workflow包含多个action,coordinator定时调度workflow,再用bundle将多个coordinator绑定,形成一个完整的调度流程。具体涉及到的配置文件包括workflow1.xml、workflow2.xml、coordinator1.xml、coordinator2.xml、bundle.xml和job.properties。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

包含关系

几个包含关系:
action∈workflow∈coordinatorㄈbundle
就是workflow可以包含多可action,通过coordinator来定时调度workflow,通过bundle来绑定多个coordinator

实例

workflow1.xml

<workflow-app xmlns="uri:oozie:workflow:0.4" name="shell-wf">
    <start to="shell-node"/>
    <action name="shell-node">
        <shell xmlns="uri:oozie:shell-action:0.1">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <exec>echo</exec>
            <argument>xx="=======111111...======="</argument>
            <capture-output/>
        </shell>
        <ok to="second"/>
        <error to="fail"/>
    </action>

    <action name="second">
        <shell xmlns="uri:oozie:shell-action:0.1">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <exec>echo</exec>
            <argument>xx="=======second...======="</argument>
            <capture-output/>
        </shell>
        <ok to="third"/>
        <error to="fail"/>
    </action>

    <action name="third">
        <app-path>${workflowAppUri3}</app-path>
    </action>

    <kill name="fail">
        <message>Shell action failed, error message</message>
    </kill>
    <end name="end"/>
</workflow-app>

workflow2.xml

<workflow-app xmlns="uri:oozie:workflow:0.4" name="shell-wf">
    <start to="shell-node"/>
    <action name="shell-node">
        <shell xmlns="uri:oozie:shell-action:0.1">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <exec>echo</exec>
            <argument>xx="=======222222...======="</argument>
            <capture-output/>
        </shell>
        <ok to="end"/>
        <error to="fail"/>
    </action>

    <kill name="fail">
        <message>Shell action failed, error message</message>
    </kill>
    <end name="end"/>
</workflow-app>

coordinator1.xml

<coordinator-app name="cron-coord1" frequency="${coord:minutes(5)}" start="${start}" end="${end}" timezone="UTC"
                 xmlns="uri:oozie:coordinator:0.2">

    <action>
        <workflow>
            <app-path>${workflowAppUri1}</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>

coordinator2.xml

<coordinator-app name="cron-coord2" frequency="${coord:minutes(7)}" start="${start}" end="${end}" timezone="UTC"
                 xmlns="uri:oozie:coordinator:0.2">

    <action>
        <workflow>
            <app-path>${workflowAppUri2}</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>

bundle.xml

<bundle-app name='bundle-app' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:bundle:0.1'>

          <coordinator name='cron-coord1'>
                 <app-path>${coordinator1}</app-path>
          </coordinator>

          <coordinator name='cron-coord2'>
                 <app-path>${coordinator2}</app-path>
          </coordinator>

</bundle-app>

job.properties

nameNode=hdfs://nameservice1
jobTracker=cm:8032
queueName=default
examplesRoot=examples

oozie.libpath=${nameNode}/user/${user.name}/share/lib


# 定时任务设置

# 设置bundle路径
oozie.bundle.application.path=${nameNode}/user/${user.name}/shell/bundle.xml

start=2017-06-30T08:56Z
end=2017-06-30T09:20Z
# 定义workflow路径
workflowAppUri2=${nameNode}/user/${user.name}/shell/workflow2.xml
workflowAppUri1=${nameNode}/user/${user.name}/shell/workflow1.xml


# 定义coordinator
coordinator1=${nameNode}/user/${user.name}/shell/coordinator1.xml
coordinator2=${nameNode}/user/${user.name}/shell/coordinator2.xml

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值