Workflow-Shell Action

本workflow位于oozie目录下新创建的一个oozie-apps文件夹下的shell文件夹中。

作用为:用hive执行 hive -f user.sql  语句

shell:

1、job.properties

2、test.sh         (shell脚本)

3、user.sql       (hive的一个查询语句)

3、workflow.xml

将整个oozie-apps文件夹上传到hdfs的对应用户目录下

然后运行程序

bin/oozie job -config oozie-apps/shell/job.properties -run


user.sql

insert overwrite directory '/user/bpf/ozzie/datas/shell/output'
select * from default.user

test.sh

#!/bin/bash
/opt/cdh-5.5.0/hive-1.1.0-cdh5.5.0/bin/hive -f user.sql

job.properties

nameNode=hdfs://BPF:9000
jobTracker=BPF:8032
queueName=default
oozieappsRoot=user/bpf/oozie-apps
DataRoot=user/bpf/oozie/datas
EXEC=test.sh
script=user.sql

oozie.wf.application.path=${nameNode}/${oozieappsRoot}/shell/workflow.xml

workflow.xml

<workflow-app xmlns="uri:oozie:workflow:0.5" name="shell-wf">
    <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}/${oozieappsRoot}/shell/${EXEC}#${EXEC}</file>
            <file>${nameNode}/${oozieappsRoot}/shell/${script}#${script}</file>
            <capture-output/>
        </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"/>
</workflow-app>






发布了65 篇原创文章 · 获赞 14 · 访问量 4万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章