目錄
1.7 Sqoop
1.7.1 Sqoop引數
1.7.2 Sqoop匯入匯出Null存盤一致性問題
1.7.3 Sqoop資料匯出一致性問題
1.7.4 Sqoop底層運行的任務是什么
1.7.5 Sqoop一天匯入多少資料
1.7.6 Sqoop資料匯出的時候一次執行多長時間
1.7.7 Sqoop在匯入資料的時候資料傾斜
1.7.8 Sqoop資料匯出Parquet(專案中遇到的問題)
1.10 Scala wordcount + topn
1.7 Sqoop
1.7.1 Sqoop引數
/opt/module/sqoop/bin/sqoop import \
--connect \
--username \
--password \
--target-dir \
--delete-target-dir \
--num-mappers \
--fields-terminated-by \
--query "$2" ' and $CONDITIONS;'
1.7.2 Sqoop匯入匯出Null存盤一致性問題
Hive中的Null在底層是以“\N”來存盤,而MySQL中的Null在底層就是Null,為了保證資料兩端的一致性,在匯出資料時采用--input-null-string和--input-null-non-string兩個引數,匯入資料時采用--null-string和--null-non-string,
1.7.3 Sqoop資料匯出一致性問題
場景1:如Sqoop在匯出到Mysql時,使用4個Map任務,程序中有2個任務失敗,那此時MySQL中存盤了另外兩個Map任務匯入的資料,此時老板正好看到了這個報表資料,而開發工程師發現任務失敗后,會除錯問題并最終將全部資料正確的匯入MySQL,那后面老板再次看報表資料,發現本次看到的資料與之前的不一致,這在生產環境是不允許的,
官網:http://sqoop.apache.org/docs/1.4.6/SqoopUserGuide.html
Since Sqoop breaks down export process into multiple transactions, it is possible that a failed export job may result in partial data being committed to the database. This can further lead to subsequent jobs failing due to insert collisions in some cases, or lead to duplicated data in others. You can overcome this problem by specifying a staging table via the --staging-table option which acts as an auxiliary table that is used to stage exported data. The staged data is finally moved to the destination table in a single transaction.
–staging-table方式
sqoop export --connect jdbc:mysql://192.168.137.10:3306/user_behavior --username root --password 123456 --table app_cource_study_report --columns watch_video_cnt,complete_video_cnt,dt --fields-terminated-by "\t" --export-dir "/user/hive/warehouse/tmp.db/app_cource_study_analysis_${day}" --staging-table app_cource_study_report_tmp --clear-staging-table --input-null-string '\N'
1.7.4 Sqoop底層運行的任務是什么
只有Map階段,沒有Reduce階段的任務,默認是4個MapTask,
1.7.5 Sqoop一天匯入多少資料
100萬榷訓=》10萬訂單,1人10條,每天1g左右業務資料
Sqoop每天將1G的資料量匯入到數倉,
1.7.6 Sqoop資料匯出的時候一次執行多長時間
每天晚上00:10開始執行,Sqoop任務一般情況20-30分鐘的都有,取決于資料量(11:11,6:18等活動在1個小時左右),
1.7.7 Sqoop在匯入資料的時候資料傾斜
Sqoop 引數撇嘴: split-by:按照自增主鍵來切分表的作業單元,
num-mappers:啟動N個map來并行匯入資料,默認4個;
1.7.8 Sqoop資料匯出Parquet(專案中遇到的問題)
Ads層資料用Sqoop往MySql中匯入資料的時候,如果用了orc(Parquet)不能匯入,需轉化成text格式
(1)創建臨時表,把Parquet中表資料匯入到臨時表,把臨時表匯出到目標表用于可視化
(2)ads層建表的時候就不要建Parquet表
1.10 Scala wordcount + topn


轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/263416.html
標籤:其他
