gpt4 book ai didi

hadoop - 在sqoop未将数据加载到HDFS中的apache配置单元中增量数据加载的最佳方法

转载 作者:行者123 更新时间:2023-12-02 20:47:28 25 4
gpt4 key购买 nike

我有一种情况-使用实用程序数据文件[每次都使用相同的名称-首先删除旧文件,然后加载更新的/最新的文件之后]被定期从源系统推送到HDFS的定义位置。
该数据文件需要进一步推送到配置单元表中。

我正在寻找实现这一目标的最佳方法:

1) Create an external table in hive pointing to position in HDFS where data is pushed by the utility in HDFS, this will keep updating the hive table data by itself as soon as the data file is updated by the utility.

2) Create an internal/managed table hi hive with data present in hive warehouse. Now using a shell script configured as cron job - in regular interval check the timestamp of file present in hive warehouse and file present at location where utility is pushing/updating the data, if timestamp is not same then the script will delete the file from hive warehouse and copy the latest file into it.

3) Every time create new hive table with some other name, load the latest data file into it, delete old table and finally rename the new table to old table name in hive.

4) Any other approach?



我需要专家评论哪种方法似乎是最好的???我还担心一种情况,在这种情况下,我将使用这些方法中的任何一种来执行任何数据文件更改,并且有人同时访问该表。是否有任何方法可以避免这种情况?

注意:不会通过Sqoop将数据加载到HDFS / Hive中作为增量加载。同样,每次更新的文件将再次具有完整的旧/更新数据以及新数据。因此,此文件的大小可能会随着时间的推移而增加,因为它将同时包含旧数据,更新数据和新数据。

问候,
布普什

最佳答案

如果您使用的Hive版本高于0.14,则可以执行上述操作。您应该使用hive的upsert功能。

  • 您可以创建一个外部表和一个托管表。两者应具有相同的表结构
    -外部表将包含实用程序文件中的所有数据(原始表单),并且您可以通过upsert功能进行更新,并根据需要(SCD II)将其插入内部表中。我在 A下创建的示例作为外部以及 B作为内部。更多信息,请参见https://hortonworks.com/blog/update-hive-tables-easy-way/
    merge into A
    using B on A.id = B.id
    when matched then update set
    email=B.email,
    when not matched then insert
    values(B.id, B.email);
  • 最后,您可以设置一个oozie工作流程,该工作流程将定期执行插入/更新/删除操作或设置任何cron作业。此外,您还需要定期从外部表中删除数据以维护hdfs。



  • 您可以使用kudu代替 hive 。请在此处引用我的 answer

    关于hadoop - 在sqoop未将数据加载到HDFS中的apache配置单元中增量数据加载的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47373972/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com