Oozie 实战之 shell

本文介绍如何通过Oozie工作流调度系统使用shell action执行Hive SQL查询。包括创建shell脚本hive-select-test.sh、HQL文件select.sql、配置job.properties文件及workflow.xml文件等步骤。

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

说明:使用 shell action 执行 shell 脚本 hive-select-test.sh 来通过已经配置好的 Hive -f 来执行 HQL 查询脚本文件 select.sql

1.创建脚本文件 hive-select-test.sh

#!/bin/sh
/opt/cdh5.3.6/hive-1.1.0-cdh5.12.0/bin/hive -f select.sql

2.创建 HQL 文件 select.sql

insert overwrite directory '/user/cen/oozie-apps/shell-hive-select/output/' select count(1)  cnt from default.test; 

3.修改 job.properties 文件

nameNode=hdfs://cen-ubuntu.cenzhongman.com:8020
jobTracker=localhost:8032
queueName=default
oozieAppsRoot=oozie-apps

oozie.wf.application.path=${nameNode}/user/cen/${oozieAppsRoot}/shell-hive-select/
EXEC=hive-select-test.sh
script=select.sql

4.修改 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}/user/cen/${oozieAppsRoot}/shell-hive-select/${EXEC}#${EXEC}</file>
            <file>${nameNode}/user/cen/${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>

注意事项

  • workflow 版本0,5 sqoop action 版本0.2
  • 使用的是新版本的API,但旧版本依旧支持使用(可以不用改)
  • 关于file作用和配置,下文会说明

5.上传文件到HDFS文件系统

6.执行程序

export OOZIE_URL=http://cen-ubuntu:11000/oozie/
bin/oozie job --config oozie-apps/shell-hive-select/job.properties -run

转载于:https://www.cnblogs.com/cenzhongman/p/7253157.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值