大數據--sqoop數據增量導入


1、在MySQL中新建表stu,插入一些數據

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

 

 2、將MySQL表的stu中的數據導入到hive中

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

[root@bigdata113 ~]# sqoop import --connect jdbc:mysql://bigdata113:3306/mysqlhdfs --username root --password 000000 --table stu --delete-target-dir --num-mappers 1 --hive-import --fields-terminated-by "\t" --hive-overwrite --hive-table stu_hive

hive (default)> select * from stu_hive;
OK
stu_hive.id stu_hive.name
1 zhangsan
2 isi
3 wangwu
4 yiliu
5 lisa
Time taken: 0.491 seconds, Fetched: 5 row(s)

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

3、往MySQL表stu中添加新數據

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

 

 

4、將MySQL表stu新增的數據追加到hive的stu_hive中

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

[root@bigdata113 ~]# sqoop import --connect jdbc:mysql://bigdata113:3306/mysqlhdfs --username root --password 000000 --table stu --num-mappers 1 --fields-terminated-by "\t" --target-dir /user/hive/warehouse/stu_hive --check-column id --incremental append --last-value 5

hive (default)> select * from stu_hive;
OK
stu_hive.id stu_hive.name
1 zhangsan
2 isi
3 wangwu
4 yiliu
5 lisa
6 xiaohei
Time taken: 0.091 seconds, Fetched: 6 row(s)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM