Hadoop DistCp使用通配符? [英] Hadoop DistCp using wildcards?

查看:888
本文介绍了Hadoop DistCp使用通配符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用DistCp复制仅匹配特定模式的文件?
例如。对于/ foo我只想要* .log文件。

解决方案

我意识到这是一个古老的线程。但我自己对这个问题的答案感兴趣 - 而且dk89在2013年也再次提出了问题。因此,我们继续:
$ b distcp不支持通配符。您可以做的最接近的是:



找到您想要复制的文件(来源),然后使用grep进行过滤,使用awk格式化hdfs,并将结果输出到一个输入文件列表:

  hadoop dfs -lsr hdfs:// localhost:9000 / path / to / source / dir / 
| grep -e webapp.log.3。 | awk'{printhdfs\:// localhost \:9000 /$ 8'}> input-files.txt

将输入文件列表放入hdfs中

  hadoop dfs -put input-files.txt。 

创建目标目录

  hadoop dfs -mkdir hdfs:// localhost:9000 / path / to / target / 

使用输入文件列表运行distcp并指定目标hdfs目录:

  hadoop distcp -i -f input -files.txt hdfs:// localhost:9000 / path / to / target / 


Is it possible to use DistCp to copy only files that match a certain pattern? For example. For /foo I only want *.log files.

解决方案

I realize this is an old thread. But I was interested in the answer to this question myself - and dk89 also asked again in 2013. So here we go:

distcp does not support wildcards. The closest you can do is to:

Find the files you want to copy (sources), filter then using grep, format for hdfs using awk, and output the result to an "input-files" list:

hadoop dfs -lsr hdfs://localhost:9000/path/to/source/dir/ 
  | grep -e webapp.log.3. | awk '{print "hdfs\://localhost\:9000/" $8'}   > input-files.txt

Put the input-files list into hdfs

hadoop dfs -put input-files.txt  .

Create the target dir

hadoop dfs -mkdir hdfs://localhost:9000/path/to/target/

Run distcp using the input-files list and specifying the target hdfs dir:

hadoop distcp -i -f input-files.txt hdfs://localhost:9000/path/to/target/  

这篇关于Hadoop DistCp使用通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆