天天看點

利用Sqoop将MySQL資料導入Hive中

參考

http://www.cnblogs.com/iPeng0564/p/3215055.html

http://www.tuicool.com/articles/j2yayyj

http://blog.csdn.net/jxlhc09/article/details/16856873

1.list databases

sqoop list-databases --connect jdbc:mysql://192.168.2.1:3306/ --username sqoop --password sqoop

2.用sqoop建立hive表

sqoop create-hive-table    --connect    jdbc:mysql://xx:3306/test?characterEncoding=UTF-8    --table employee     --username   root   -password 'xx'  --hive-database  db_hive_edu  

3.import資料

#sqoop    import     --connect     jdbc:mysql://xx:3306/test?characterEncoding=UTF-8        --table employee    --username   root  -password  'xx'    --fields-terminated-by   ','    --hive-import      --hive-database  db_hive_edu     -m  1 

--fields-terminated-by   ',' 導緻資料變成null

sqoop import --connect jdbc:mysql://xx:3306/test?characterEncoding=UTF-8 --username root -password 'xx' --table employee --hive-import --hive-database  db_hive_edu -m 1

截圖

<a href="https://s1.51cto.com/wyfs02/M00/9A/07/wKioL1lQh__waDjzAABs9h_1ukc926.png-wh_500x0-wm_3-wmp_4-s_219995857.png" target="_blank"></a>

如果需要實時同步,不再手動,參考

利用Flume将MySQL表資料準實時抽取到HDFS - wzy0623的專欄 - 部落格頻道 - CSDN.NET

利用Sqoop将MySQL資料導入Hive中

本文轉自 liqius 51CTO部落格,原文連結:http://blog.51cto.com/szgb17/1941914,如需轉載請自行聯系原作者