首页 > 其他 > 详细

大数据--sqoop数据增量导入

时间:2019-10-06 14:58:16      阅读:95      评论:0      收藏:0      [点我收藏+]

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)

大数据--sqoop数据增量导入

原文:https://www.cnblogs.com/jeff190812/p/11627269.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!