我想将mysql表同步到配置单元表中。因为orders表中的记录通常会在不久的将来更改。我需要将它们更新为蜂巢。

例如 ,


我将所有mysql数据转储到配置单元中
日常工作检查time_update在近1天内的更改记录,并将它们更新到配置单元表中。


我已经尝试过--incremental lastmodified如下

sqoop import \
"-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect $DB_URL \
--username $USERNAME \
--password $PASSWORD \
--direct \
--fields-terminated-by '\t' \
--target-dir '/data/hive/' \
--delete-target-dir \
--hive-database $HIVE_DB \
--hive-table $HIVE_TABLE \
--hive-import \
--hive-overwrite \
--create-hive-table \
--query 'select * from '$HIVE_TABLE' where $CONDITIONS' \
--split-by id \
-m 6 \
--merge-key id \
--incremental lastmodified \
--check-column time_update \
--last-value "2019-01-01 21:00:00"


错误--incremental lastmodified option for hive imports is not supported. Please remove the parameter --incremental lastmodified.

没有--incremental lastmodified option的正确方法是什么?

最佳答案

首先,您必须像在增量导入中一样删除--delete-target-dir和--create-hive-table参数,目标目录将保持不变,因此--delete-target-dir无法与--incremental一起使用论点。另外,配置单元表只能创建一次,因此您必须删除--create-hive-table参数,并在具有相同模式的配置单元中手动创建配置单元表,获取该模式的位置并将其用作--target-dir。

sqoop import \
--connect <<db_url>> \
--username <<username>> \
--password <<password>> \
--direct \
--fields-terminated-by '\t' \
--hive-database <<hive_db>> \
--hive-table <<hive_table>> \
--hive-import \
--hive-overwrite \
--query 'select * from <<db_table>> where $CONDITIONS' \
--split-by product_id \
-m 6 \
--merge-key product_id \
--incremental lastmodified \
--check-column timedate \
--last-value 0 \
--target-dir /user/hive/warehouse/problem5.db/products_hive (<<hive_table_location>>)


如果不告诉我,它将成功运行。

关于mysql - 如何将mysql表同步到配置单元表? (不支持sqoop --incremental lastmodified配置单元导入),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54141213/

10-12 23:45