Oozie WorkFlow中Shell Action使用案例

  • cp -r examples/apps/shell oozie-apps/

  • mv shell shell-hive-select

  • touch student-select.sh

#!/usr/bin/env bash

+ ##student select
/opt/cdh5.3.6/hive-0.13.1-cdh5.3.6/bin/hive -f student-select.sql

  • vi student-select.sql

insert overwrite directory '/user/beifeng/oozie/datas/shell-hive-select/output'
select dept_no,dept_name from default.dept; 

  • job.properties

nameNode=hdfs://hadoop-senior.beifeng.com:8020
jobTracker=hadoop-senior.beifeng.com:8032
queueName=default
examplesRoot=examples
oozieAppsRoot=user/beifeng/oozie-apps
oozieDataRoot=user/beifeng/oozie/datas

oozie.wf.application.path=${nameNode}/${oozieAppsRoot}/shell-hive-select/
EXEC=student-select.sh
script=student-select.sql
  • 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-hive-select/${EXEC}#${EXEC}</file>
            <file>${nameNode}/${oozieAppsRoot}/shell-hive-select/${script}#${script}</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"/>
</workflow-app>
  • 查看运行日志
http://hadoop-senior.beifeng.com:19888/jobhistory/logs/hadoop-senior.beifeng.com:49066/container_1521081924307_0045_01_000002/attempt_1521081924307_0045_m_000000_0/beifeng
  • 查看运行结果


bin/hdfs dfs -text /user/beifeng/oozie/datas/shell-hive-select/output/*
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容