溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

利用oozie,執(zhí)行sqoop action將DB2中的數(shù)據(jù)導入到hive分區(qū)表中

發(fā)布時間:2020-07-21 12:46:12 來源:網(wǎng)絡(luò) 閱讀:1384 作者:白話 欄目:大數(shù)據(jù)

測試:利用oozie,執(zhí)行sqoop action將DB2中的數(shù)據(jù)導入到hive分區(qū)表中。

 

需要注意的地方:

1,要添加hive.metastore.uris這個參數(shù)。否則無法將數(shù)據(jù)加載到hive表中。并且,如果一個xml文本中有多個這種操作的話,每個action中都需要配置這個參數(shù)。

2,要注意XML中的轉(zhuǎn)義字符問題。這里我的sql中,就有一個小于號需要重寫,否則執(zhí)行后會說sql語句不對。

3,因為是分區(qū)表,按照每日分區(qū),所以要從系統(tǒng)獲取系統(tǒng)時間。這里沒找到其他的可執(zhí)行的方法,就比較麻煩的寫成了這個樣子:${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問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI