我正在尝试使用 S3-Dist-Cp 命令在每日运行后将日志文件从 EMR 集群写入我的 S3 存储桶。如果 S3 文件中已存在该文件(具有相同名称),S3-Dist-Cp 会写入一个新文件,并在文件名后附加一个数字。
有没有办法使用 S3-Dist-Cp 覆盖 S3 中的现有文件(我没有看到 AWS 的 S3DistCp 文档的 -overwrite Flag 或 -delete flag)?
我正在努力寻找一种在我的AWS EMR集群中使用S3DistCp的方法。
一些旧示例显示了如何将s3distcp添加为EMR步骤use elastic-mapreduce
命令,该命令已不再使用。
其他一些消息来源建议使用s3-dist-cp
命令,该命令在当前EMR群集中找不到。甚至官方文档(在线和EMR开发人员指南2016 pdf)也提供了这样的示例:
aws emr add-steps --cluster-id j-3GYXXXXXX9IOK --steps Type=CUSTOM_JAR,Name="S3DistCp step",Jar=/home/hadoop/lib/emr-s3distcp-1.0.jar,Args=["--s3Endpoint,s3-eu-west-1.amazonaws.com","--src,s3://mybucket/logs/j-3GYXXXXXX9IOJ/node/","--dest,hdfs:///output","--srcPattern,.*[azA-Z,]+"]
Run Code Online (Sandbox Code Playgroud)
但是路径中没有lib
文件夹/home/hadoop
。我在此文件夹中找到了一些hadoop库:/usr/lib/hadoop/lib
,但找不到s3distcp
任何地方。
然后我发现在某些S3存储桶中有一些可用的库。例如,从这个问题中,我找到了以下路径:s3://us-east-1.elasticmapreduce/libs/s3distcp/1.latest/s3distcp.jar
。这似乎是朝着正确方向迈出的一步,因为使用这些参数从AWS界面向正在运行的EMR集群添加了一个新步骤,从而开始了该步骤(之前没有尝试过该步骤),但在约15秒后失败了:
JAR location: s3://us-east-1.elasticmapreduce/libs/s3distcp/1.latest/s3distcp.jar
Main class: None
Arguments: --s3Endpoint s3-eu-west-1.amazonaws.com --src s3://source-bucket/scripts/ --dest hdfs:///output
Action on failure: Continue
Run Code Online (Sandbox Code Playgroud)
这导致以下错误:
Exception in thread "main" java.lang.RuntimeException: Unable to retrieve Hadoop configuration for key fs.s3n.awsAccessKeyId
at com.amazon.external.elasticmapreduce.s3distcp.ConfigurationCredentials.getConfigOrThrow(ConfigurationCredentials.java:29)
at com.amazon.external.elasticmapreduce.s3distcp.ConfigurationCredentials.<init>(ConfigurationCredentials.java:35)
at com.amazon.external.elasticmapreduce.s3distcp.S3DistCp.createInputFileListS3(S3DistCp.java:85)
at com.amazon.external.elasticmapreduce.s3distcp.S3DistCp.createInputFileList(S3DistCp.java:60)
at com.amazon.external.elasticmapreduce.s3distcp.S3DistCp.run(S3DistCp.java:529)
at com.amazon.external.elasticmapreduce.s3distcp.S3DistCp.run(S3DistCp.java:216)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84) …
Run Code Online (Sandbox Code Playgroud) 我在 emr-5.0.0 版本中遇到 s3-dist-cp 命令的问题。在我的应用程序中,我需要将一些文件从 hdfs 推送到 S3。我正在使用 s3-dist-cp 命令来实现此目的。在 emr-4.2.0 中运行良好。但它在 emr-5.0.0 中不起作用。如果我手动运行该命令,它工作正常。但它在我的应用程序中失败了。我没有对我的应用程序进行任何更改以在 emr-5 上运行它。
如果我需要使用 emr-5,我需要进行任何更改吗?emr-5 中使用 s3-dist-cp 命令的方式有什么变化吗?
我正在使用以下命令:
s3-dist-cp --src /user/hive/warehouse/abc.text --dest s3n://bucket/abc.text
Run Code Online (Sandbox Code Playgroud) 我正在使用aws .net sdk向EMR运行s3distcp作业,以使用--groupBy arg连接文件夹中的所有文件.但无论我尝试过什么"groupBy"arg,它都会一直失败,或者只是复制文件而不连接,就像在arg列表中指定没有--groupBy一样.
文件夹中的文件是spark saveAsTextFiles,如下所示:
部分0000
兼职0001
兼职技术
...
...
step.HadoopJarStep = new HadoopJarStepConfig
{
Jar = "/usr/share/aws/emr/s3-dist-cp/lib/s3-dist-cp.jar",
Args = new List<string>
{
"--s3Endpoint=s3-eu-west-1.amazonaws.com",
"--src=s3://foo/spark/result/bar" ,
"--dest=s3://foo/spark/result-merged/bar",
"--groupBy=(part.*)",
"--targetSize=256"
}
};
Run Code Online (Sandbox Code Playgroud) 只是想知道是否可以使用 s3-dist-cp 工具来合并镶木地板文件(快速压缩)。我尝试使用“--groupBy”和“--targetSize”选项,它确实将小文件合并为大文件。但是我无法在 Spark 或 AWS Athena 中读取它们。在 aws athena 中,我收到以下错误:
HIVE_CURSOR_ERROR: Expected 246379 values in column chunk at s3://my_analytics/parquet/auctions/region=us/year=2017/month=1/day=1/output123 offset 4 but got 247604 values instead over 1 pages ending at file offset 39
This query ran against the "randomlogdatabase" database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id: 4ff77c55-3b69-414d-8fd9-a3d135f5ff2f.
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏。
I have a huge bucket of S3files that I want to put on HDFS. Given the amount of files involved my preferred solution is to use 'distributed copy'. However for some reason I can't get hadoop distcp to take my Amazon S3 credentials. The command I use is:
hadoop distcp -update s3a://[bucket]/[folder]/[filename] hdfs:///some/path/ -D fs.s3a.awsAccessKeyId=[keyid] -D fs.s3a.awsSecretAccessKey=[secretkey] -D fs.s3a.fast.upload=true
Run Code Online (Sandbox Code Playgroud)
However that acts the same as if the '-D' arguments aren't there.
ERROR tools.DistCp: Exception encountered
java.io.InterruptedIOException: doesBucketExist on [bucket]: com.amazonaws.AmazonClientException: …
Run Code Online (Sandbox Code Playgroud) 我在初始EMR步骤中将一棵文件树从S3复制到具有S3DistCP的 HDFS 。hdfs dfs -ls -R hdfs:///data_dir
显示预期的文件,如下所示:
/data_dir/year=2015/
/data_dir/year=2015/month=01/
/data_dir/year=2015/month=01/day=01/
/data_dir/year=2015/month=01/day=01/data01.12345678
/data_dir/year=2015/month=01/day=01/data02.12345678
/data_dir/year=2015/month=01/day=01/data03.12345678
Run Code Online (Sandbox Code Playgroud)
“目录”被列出为零字节文件。
然后,我运行一个启动步骤,该步骤需要读取这些文件。因此,加载代码为:
sqlctx.read.json('hdfs:///data_dir, schema=schema)
Run Code Online (Sandbox Code Playgroud)
作业失败,出现Java异常
java.io.IOException: Not a file: hdfs://10.159.123.38:9000/data_dir/year=2015
Run Code Online (Sandbox Code Playgroud)
我曾经(也许很幼稚)假设spark会递归地下降“ dir tree”并加载数据文件。如果我指向S3,它将成功加载数据。
我误会了HDFS吗?我可以告诉spark忽略零字节文件吗?我可以使用S3DistCp压扁树吗?
我在 HDFS 中有以下 2 个文件和 1 个目录。
-rw-r--r-- 1 hadoop hadoop 11194859 2017-05-05 19:53 hdfs:///outputfiles/abc_output.txt
drwxr-xr-x - hadoop hadoop 0 2017-05-05 19:28 hdfs:///outputfiles/sample_directory
-rw-r--r-- 1 hadoop hadoop 68507436 2017-05-05 19:55 hdfs:///outputfiles/sample_output.txt
I want to copy abc_output.txt and sample_directory in gzip format onto S3 from HDFS in a single command. I don't want the files to be combined on S3.
My S3 bucket should contain the following: abc_output.txt.gzip sample_directory.gzip
I tried the following:
s3-dist-cp --s3Endpoint=s3.amazonaws.com --src=hdfs:///outputfiles/ --dest=s3://bucket-name/outputfiles/ --outputCodec=gzip
But this copies …
我正在尝试使用 s3-distcp 将数据从 EMR 集群复制到 S3。我可以将减速器的数量指定为比默认值更大的值,以加快我的流程吗?
s3distcp ×9
amazon-emr ×6
amazon-s3 ×5
distcp ×3
apache-spark ×1
aws-sdk ×1
emr ×1
hadoop ×1
hdfs ×1
parquet ×1