使用s3distcp和amazon emr复制单个文件

isr3a4wc  于 2021-06-03  发布在  Hadoop
关注(0)|答案(2)|浏览(381)

我只想使用s3distcp将一个文件复制到hdfs。我尝试过使用srcpattern参数,但没有用,它一直抛出java.lang.runtime异常。有可能是我使用的正则表达式是罪魁祸首,请帮助。
我的代码如下:

elastic-mapreduce -j $jobflow --jar s3://us-east-1.elasticmapreduce/libs/s3distcp/1.latest/s3distcp.jar --args '--src,s3://<mybucket>/<path>' --args '--dest,hdfs:///output' --arg --srcPattern --arg '(filename)'

引发异常:

Exception in thread "main" java.lang.RuntimeException: Error running job at com.amazon.external.elasticmapreduce.s3distcp.S3DistCp.run(S3DistCp.java:586) at com.amazon.external.elasticmapreduce.s3distcp.S3DistCp.run(S3DistCp.java:216) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79) at com.amazon.external.elasticmapreduce.s3distcp.Main.main(Main.java:12) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.hadoop.util.RunJar.main(RunJar.java:156) Caused by: org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: hdfs:/tmp/a088f00d-a67e-4239-bb0d-32b3a6ef0105/files at org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:197) at org.apache.hadoop.mapred.SequenceFileInputFormat.listStatus(SequenceFileInputFormat.java:40) at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:208) at org.apache.hadoop.mapred.JobClient.writeOldSplits(JobClient.java:1036) at org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:1028) at org.apache.hadoop.mapred.JobClient.access$700(JobClient.java:172) at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:944) at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:897) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:396) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1059) at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:897) at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:871) at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1308) at com.amazon.external.elasticmapreduce.s3distcp.S3DistCp.run(S3DistCp.java:568) ... 9 more
nnsrf1az

nnsrf1az1#

我使用的正则表达式确实是罪魁祸首。假设文件名有日期,例如 d-2013-06-12.gz ,则要仅复制此文件,应执行以下emr命令:
elastic mapreduce-j$jobflow--jar s3://us-east-1.elasticmapreduce/libs/s3distcp/1.latest/s3distcp.jar--args'--src,s3://'--args'--dest,hdfs:///output'--arg--srcpattern--arg'.*2013-06-12.gz'
如果我没记错的话,我的正则表达式最初是 *2013-06-12.gz 而不是 .*2013-06-12.gz . 所以需要一开始的圆点。

shyt4zoc

shyt4zoc2#

distcp旨在使用许多机器复制许多文件。如果只想复制一个文件,distcp不是合适的工具。
在hadoop主节点上,可以使用 hadoop fs -cp s3://<mybucket>/<path> hdfs:///output

相关问题