Workflow-Hive Action

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

hive-select

1、job.properties

2、lib文件夹(其中包含了一个mysql的驱动包)

3、workflow.xml

4、hive-site.xml

5、select-user.sql

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

然后运行程序

bin/oozie job -config oozie-apps/hive-select/job.properties -run


job.properties

nameNode=hdfs://BPF:9000
jobTracker=BPF:8032
queueName=default
oozieappsRoot=user/bpf/oozie-apps
DataRoot=user/bpf/oozie/datas

oozie.use.system.libpath=true

oozie.wf.application.path=${nameNode}/${oozieappsRoot}/hive-select/workflow.xml
outputDir=hive-select/output

hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>

<property>
  <name>hive.cli.print.header</name>
  <value>true</value>
  <description>Whether to print the names of the columns in query output.</description>
</property>

<property>
  <name>hive.cli.print.current.db</name>
  <value>true</value>
  <description>Whether to include the current database in the Hive prompt.</description>
</property>

<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://BPF:3306/metastore?createDatabaseIfNotExist=true</value>
  <description>JDBC connect string for a JDBC metastore</description>
</property>

<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>com.mysql.jdbc.Driver</value>
  <description>Driver class name for a JDBC metastore</description>
</property>

<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>root</value>
  <description>username to use against metastore database</description>
</property>

<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>1234</value>
  <description>password to use against metastore database</description>
</property>

<property>
<name>hive.log4j.file</name>
<value>/opt/cdh-5.5.0/hive-1.1.0-cdh5.5.0/conf/hive-log4j.properties</value>
</property>

</configuration>

select-user.sql

insert overwrite directory '${OUTPUT}' 
select count(1) cnt from default.user;

workflow.xml

<workflow-app xmlns="uri:oozie:workflow:0.5" name="hive-select-wf">
    <start to="hive-node"/>

    <action name="hive-node">
        <hive xmlns="uri:oozie:hive-action:0.5">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <prepare>
                <delete path="${nameNode}/${DataRoot}/${outputDir}"/>
                <mkdir path="${nameNode}/${DataRoot}/${outputDir}"/>
            </prepare>
            <job-xml>${nameNode}/${oozieappsRoot}/hive-select/hive-site.xml</job-xml>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <script>select-user.sql</script>
            <param>OUTPUT=${nameNode}/${DataRoot}/${outputDir}</param>
        </hive>
        <ok to="end"/>
        <error to="fail"/>
    </action>

    <kill name="fail">
        <message>Hive failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name="end"/>
</workflow-app>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值