記一次從oracle到hive的曆史資料移轉(一)

來源:互聯網
上載者:User

標籤:oracle到hive 曆史資料 sqluldr2使用

介紹一下具體情境

    需要從現有在用的oracle中將曆史資料移轉出來並匯入到hive中,存在幾個問題:1、現有oracle資料庫在使用無法整個庫匯出,資料庫伺服器沒有許可權;2、由於各個資料提供方的各次升級,oracle資料庫採取添加欄位而不刪除欄位的方式更新,而hive中建立的表資料結構要按新的來,也就是說oracle匯出的資料到hive表中需要做欄位對應。

    決定先將oracle匯入到另一個oracle中,將oracle中表欄位和hive中的表欄位進行比對得到各個的對應關係,之後寫對應的sqoop語句對應利用ETL流程安裝賬期一天一天匯入。 

    從一個oracle到另一個oracle匯入的方案,利用大神寫出的sqluldr2 工具用來匯出資料,匯入利用

sqlldr 命令匯入到另一個庫表中。

   匯出的具體命令

sqluldr2.bin user=root/[email protected] query="select /*+ parallel(8) */ * from table   " head=no File=/data/oracle/tmp/file 匯出到本地目錄

  匯入的具體命令

sqlldr root/[email protected]@ip:1521/tnsname control=/data/oracle/shell/xxx.ctl 

data=/data/oracle/tmp/file

log=/data/oracle/log/file.log errors=0 rows=100000 bindsize=1024000000 direct=y;

xxx.ctl 是用來指定匯入表的欄位和分割符如下寫法

load data

truncate into table  tablename

Fields terminated by ‘,‘ #檔案的資料行分隔符號

TRAILING NULLCOLS

IP char(255), 

APPKEY char(255), 

PLATFORM char(255), 

PORTAL char(255), 

COMPANYID char(255) )


記一次從oracle到hive的曆史資料移轉(一)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.