温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

利用oozie,执行sqoop action将DB2中的数据导入到hive分区表中

发布时间:2020-07-21 12:46:12 来源:网络 阅读:1380 作者:白话 栏目:大数据

测试:利用oozie,执行sqoop action将DB2中的数据导入到hive分区表中。

 

需要注意的地方:

1,要添加hive.metastore.uris这个参数。否则无法将数据加载到hive表中。并且,如果一个xml文本中有多个这种操作的话,每个action中都需要配置这个参数。

2,要注意XML中的转义字符问题。这里我的sql中,就有一个小于号需要重写,否则执行后会说sql语句不对。

3,因为是分区表,按照每日分区,所以要从系统获取系统时间。这里没找到其他的可执行的方法,就比较麻烦的写成了这个样子:${replaceAll(timestamp(),"T.{0,}","")}

4,还要注意xmlns的版本问题。这个时候,多试几个就好了。


workflow.xml

<?xml version="1.0" encoding="gb2312"?>

<workflow-app name="workID1" xmlns="uri:oozie:workflow:0.5">

    <start to="step0101"/>

    <action name="step0101">

        <sqoop xmlns="uri:oozie:sqoop-action:0.4">

        <configuration>

        <property>

        <name>hive.metastore.uris</name>

        <value>thrift://192.168.20.39:9083</value>

        </property>

        </configuration>

            <arg>import</arg>

            <arg>--connect</arg>

            <arg>jdbc:db2://192.168.20.236:50001/sample</arg>

            <arg>--username</arg>

            <arg>db2inst1</arg>

            <arg>--password</arg>

            <arg>zheshimima</arg>

            <arg>--query</arg>

            <arg>select projno,projname,prstdate from project where prstdate &lt; date(current date)-1 day and $CONDITIONS</arg>

            <arg>--fields-terminated-by</arg>

            <arg>"\t"</arg>

            <arg>--hive-import</arg>

            <arg>--target-dir</arg>

            <arg>/qpf/target-dir/</arg>

            <arg>--hive-table</arg>

            <arg>ceshiku.tb_db2test</arg>

            <arg>--null-string</arg>

            <arg>"\\N"</arg>

            <arg>--null-non-string</arg>

            <arg>"\\N"</arg>

            <arg>--hive-partition-key</arg>

            <arg>shijian</arg>

            <arg>--hive-partition-value</arg>

            <arg>"${replaceAll(timestamp(),"T.{0,}","")}"</arg>

            <arg>-m</arg>

            <arg>1</arg>    

        </sqoop>

        <ok to="end"/>

        <error to="Kill0101" />

    </action>

    <kill name="Kill0101">

        <message>Action failed,step01 error message[${wf:errorMessage(wf:lastErrorNode())}]</message>

    </kill> 

    <end name="end"/>

</workflow-app>


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI