对于s3distcp多个源文件 [英] Multiple source files for s3distcp

查看:249
本文介绍了对于s3distcp多个源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来复制文件的从S3到HDFS ,而不是完整的文件夹中使用s3distcp的名单?这是当srcPattern不能工作。

Is there a way to copy a list of files from S3 to hdfs instead of complete folder using s3distcp? this is when srcPattern can not work.

我有一个S3文件夹中所有具有不同名称的多个文件。我想只有特定的文件复制到HDFS目录。我没有发现任何方式指定多个源文件路径s3distcp。

I have multiple files on a s3 folder all having different names. I want to copy only specific files to a hdfs directory. I did not find any way to specify multiple source files path to s3distcp.

这是我目前使用的解决办法是告诉在srcPattern所有的文件名

Workaround that I am currently using is to tell all the file names in srcPattern

hadoop jar s3distcp.jar
    --src s3n://bucket/src_folder/
    --dest hdfs:///test/output/
    --srcPattern '.*somefile.*|.*anotherone.*'

可这件事的工作时,文件的数量实在是太多了?像约10 000?

Can this thing work when the number of files is too many? like around 10 000?

推荐答案

Hadoop的DistCp使用应该解决您的问题。 我们可以用DistCp使用从S3将数据复制到HDFS。

hadoop distcp should solve your problem. we can use distcp to copy data from s3 to hdfs.

和它也支持通配符,我们可以提供在命令多个源路径。

And it also supports wildcards and we can provide multiple source paths in the command.

http://hadoop.apache.org/docs/r1.2.1/ distcp.html

通过使用一节这个特殊的URL访问

Go through the usage section in this particular url

例: 考虑你有test1的文件夹中的S3存储桶(测试桶)以下文件。

Example: consider you have the following files in s3 bucket(test-bucket) inside test1 folder.

abc.txt
abd.txt
defg.txt

和test2的文件夹,里面有

And inside test2 folder you have

hijk.txt
hjikl.txt
xyz.txt

和你的HDFS路径是 HDFS://localhost.localdomain:9000 /用户/测试/

And your hdfs path is hdfs://localhost.localdomain:9000/user/test/

然后DistCp使用命令如下一个特定的模式。

Then distcp command is as follows for a particular pattern.

hadoop distcp s3n://test-bucket/test1/ab*.txt \ s3n://test-bucket/test2/hi*.txt hdfs://localhost.localdomain:9000/user/test/

这篇关于对于s3distcp多个源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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