使用 hadoop distcp 在 Hadoop 集群上复制数据时排除一些目录

问题描述

在将 hadoop 数据从一个集群复制到另一个集群时,有没有办法跳过某些目录? IE。我正在将一些数据从现有集群复制到新集群,但我不想复制当月数据。

    /user/username/year=2021/month=06/day=01
    /user/username/year=2021/month=06/day=02
    .
    .
    .

    /user/username/year=2021/month=07/day=01

我不想包含 07 月的数据。如何跳过当前月份的目录?

我正在尝试在命令中使用过滤器,但它对我不起作用。

第一种方法

    hadoop distcp  -filters /user/username/year=2021/month=07/day=0.*
     -skipcrccheck 
    -update webhdfs://<src_host>:port/user/username/year=2021/month=07
    webhdfs://<target_host>:port/user/username/year=2021/month=07

这样它就可以过滤少于 10 天的天数 ie(01,02,03,...09) 但它不接受这个 * 并显示警告。

在日志中显示找不到过滤器

webhdfs://:port//user/username/year=2021/month=07/day=0.*

即使我尝试提供完整路径直到文件名。

   I.e. webhdfs://<src_host>:port/user/username/year=2021/month=07/day=01/myfile.txt but it's showing the same issue. Can't find the filter file.

当我检查日志中的过滤器文件而不是将其显示为 / 在路径中时

webhdfs:/:port/user/username/year=2021/month=07/day=01/myfile.txt

第二种方法

    created one file "myfilter" (/user/username/myfilter.txt)

.*webhdfs://<src_host>:src_port/user/username/year=2021/month=07/hour=0.*

    hadoop distcp  -filters 
    webhdfs://<src_host>:src_port/user/username/myfilter.txt
    -skipcrccheck -update webhdfs://<src_host>: 
   <src_port>/user/username/year=2021/month=07/ 
    webhdfs://<target_host>: 
   <target_port>/user/username/year=2021/month=07/

错误

    ERROR tools.RegexcopyFilter: Can't find filters file 
    webhdfs:/<src_host>:src_port/user/myfilter.txt

在日志中,我在 webhdfs 采取 /(single /) 之后看到了这个问题,但理想情况下它应该是 double(//) 不确定这是否是这个问题,请指导。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)