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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章