sqoop 1.4

sqoop import --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --table ORG_PAY_INFO --num-mappers 2  --delete-target-dir --hive-import --hive-database bdd --hive-table ORG_PAY_INFO --hive-overwrite --fields-terminated-by '\t'
1.995 s BY01
sqoop import --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --table IY02 --num-mappers 10 --direct --target-dir /user/hive/warehouse/shebaouser --delete-target-dir --hive-import --hive-database bdd --hive-table IY02 --hive-overwrite --fields-terminated-by '\t'
2S iy02
sqoop import --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --table IY11 --num-mappers 10 --direct --target-dir /user/hive/warehouse/shebaouser --delete-target-dir --hive-import --hive-database bdd --hive-table IY11 --hive-overwrite --fields-terminated-by '\t'

--------------------------
a.sqoop create-hive-table --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --hive-table PEOPLE_BASE_INFO --table PEOPLE_BASE_INFO --fields-terminated-by '\t'

b.hive修改列類型,double格式在kettl中沒法支持,需要修改爲string
alter table org_base_info change id舊列名 id新列名 string comment 'id註釋' first;

c.sqoop導入數據
sqoop import --connect jdbc:oracle:thin:@192.168.31.222:1521:orcl --username shebaouser --password shebaouser --table PEOPLE_PAY_INFO --num-mappers 2  --delete-target-dir --hive-import --hive-database default --hive-table PEOPLE_PAY_INFO --hive-overwrite --fields-terminated-by '\t'

如果沒有主鍵,則需要指定--m 1,一個mapper

空值處理--null-string '\\N' --null-non-string '\\N'

d.hive 從hdfs中導入表數據

load data inpath '/user/hive/warehouse/shebaouser/org_base_info.txt' into table org_base_info;


e.如果hive執行where語句半天都沒有結果,一直處於hang的狀態時,檢查各個組件的配置,如果是CDH,檢查配置問題,糾正配置問題後就可以正常執行了。

------------------------------------------

spoon轉換設置不傳對應的頭,分隔符使用\t

創建一個hive表,

create table 。。。。 ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';

------------------------------------------

如果出現用戶權限的問題$ sudo -u hive sqoop import ...

發佈了504 篇原創文章 · 獲贊 35 · 訪問量 189萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章