我正在尝试根据MySQL表的记录来更新蜂巢表。
mysql-table: (table name: delimiter_test)
+---------------+-----------------+
| department_id | department_name |
+---------------+-----------------+
| 2 | Fitness |
| 3 | Footwear |
| 4 | Apparel |
| 5 | Golf |
| 6 | Outdoors |
| 7 | Fan Shop |
| 8 | Test |
+---------------+-----------------+
hive-table (table name: my_test)
2 Fitness
3 Footwear
4 Apparel
5 Golf
6 Outdoors
7 Fan Shop
我正在尝试使用sqoop,将带有dections_id 8的MySQL表中的最后一个记录导入使用Sqoop中的增量上限的MySQL表中的最后一个记录。
my-sqoop命令:
sqoop import --connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" --username xxx --password xxx --table delimiter_test --hive-import --hive-table my_test --split-by department_id --check-column department_id --incremental append --last-value 7
我没有遇到任何错误,但是带有dections_id 8的MySQL表中的额外记录没有被更新到蜂巢表中。
请建议我在哪里出错。
我不知道我们是否可能正在研究Itversity Labs。好吧,我已经使用以下代码做了这件事。可能也可能对您有用。
Hive中的第一个加载数据
sqoop import --connect jdbc:mysql://xxxxx/retail_db --username xxxx --password xxxx
--table departments --where department_id=2 --hive-import --hive-database poc --hive-table departments_sqoop
--target-dir /user/ingenieroandresangel/sqoop/dep_hive --split-by department_id -m 1
然后,我使用以下脚本执行更新:
sqoop import --connect jdbc:mysql://xxxxxx/retail_db --username xxxxx --password xxxx
--table departments --where 'department_id>=2' --hive-import --hive-database poc --hive-table departments_sqoop --incremental append
--check-column department_id --last-value 2 --target-dir /user/ingenieroandresangel/sqoop/dep_hive --split-by department_id -m 1
sqoop导入 - 连接jdbc:mysql://xxxxxxx/mysql_db-username xxxxx -password xxxx
- 桌子部门 - 目标 - dir/sqoop/dep_hive-hive-import- hive-database poc- hive-table部门-Check-Collumn Department_id--last-value 2 -m 1
#直接将数据直接附加到Hive Table时使用标签-Cremental LastModified(如果附加到HDFS文件,则可以使用 - incremental-append)
##to覆盖蜂巢表您可以添加标签 - hive-overwrite
#last-value将在文件导入中排除。