我们如何使用 linux 脚本自动执行 Sqoop 中从数据库到 HBase 的增量导入

How can we automate the incremental import in Sqoop from DB to HBase using linux script

使用 sqoop 作业,我们可以使用 --lastval

对 HBase 进行增量加载

但是我们如何用 shell 脚本做同样的事情,以及我们如何在自动化脚本时获得 --lastval

我的意思是如何存储--lastval以及如何传递给下一次

提前感谢您的帮助!!

how to store the --lastval and how to pass it to the next time?

--lastval定义为linux或unix中的别名或导出变量。可以从自动化脚本重试

once load is finish then change it to recent value, by capturing latest lastval

export lastupdatedvalue=hive -e 'select last_value from table #根据逻辑选择查询。

sqoop import --connect jdbc:mysql://localhost:3306/ydb --table <your table> --username root -P --incremental append --last-value ${lastupdatedvalue}

:

You can try a sqoop action in Oozie, it should work. Else use shell action in oozie if you prefer scripts. It is possible to schedule it using coordinator function available.

也看看

增量导入数据

To import data in increments, you use the --incremental argument with the import command. Sqoop compares the values in a check column against a reference value for the most recent import. These arguments import all rows having an id greater than 100.

--incremental
--check-column id
--last-value 100

如果您 运行 从命令行进行增量导入,Sqoop 会打印后续增量导入中的最后一个值。如果您 运行 从已保存的作业中增量导入,Sqoop 会保留已保存作业中的最后一个值。要仅导入比以前导入的行更新的行,请使用 --exec 选项。 Sqoop 仅导入 ID 大于指定行 ID 的行。