gpt4 book ai didi

python - 如何将 EMR 流作业的输出写入 HDFS?

转载 作者:可可西里 更新时间:2023-11-01 14:38:53 26 4
gpt4 key购买 nike

我看到 examples的人将 EMR 输出写入 HDFS,但我无法找到它是如何完成的示例。最重要的是,this documentation似乎是说 EMR 流作业的 --output 参数必须是 S3 存储桶。

当我实际尝试运行脚本时(在本例中,使用 python 流和 mrJob),它会抛出“无效的 S3 URI”错误。

命令如下:

python my_script.py -r emr \
--emr-job-flow-id=j-JOBID --conf-path=./mrjob.conf --no-output \
--output hdfs:///my-output \
hdfs:///my-input-directory/my-files*.gz

还有追溯...

Traceback (most recent call last):
File "pipes/sampler.py", line 28, in <module>
SamplerJob.run()
File "/Library/Python/2.7/site-packages/mrjob/job.py", line 483, in run
mr_job.execute()
File "/Library/Python/2.7/site-packages/mrjob/job.py", line 501, in execute
super(MRJob, self).execute()
File "/Library/Python/2.7/site-packages/mrjob/launch.py", line 146, in execute
self.run_job()
File "/Library/Python/2.7/site-packages/mrjob/launch.py", line 206, in run_job
with self.make_runner() as runner:
File "/Library/Python/2.7/site-packages/mrjob/job.py", line 524, in make_runner
return super(MRJob, self).make_runner()
File "/Library/Python/2.7/site-packages/mrjob/launch.py", line 161, in make_runner
return EMRJobRunner(**self.emr_job_runner_kwargs())
File "/Library/Python/2.7/site-packages/mrjob/emr.py", line 585, in __init__
self._output_dir = self._check_and_fix_s3_dir(self._output_dir)
File "/Library/Python/2.7/site-packages/mrjob/emr.py", line 776, in _check_and_fix_s3_dir
raise ValueError('Invalid S3 URI: %r' % s3_uri)
ValueError: Invalid S3 URI: 'hdfs:///input/sample'

如何将 EMR 流作业的输出写入 HDFS?有可能吗?

最佳答案

我不确定如何使用 mrJob 完成它,但是使用 hadoop 和 streaming jobs written in java ,我们这样做:

  1. 启动集群
  2. 使用 s3distcp 从 s3 获取数据到集群的HDFS
  3. 使用 HDFS 输入执行我们作业的第 1 步
  4. 使用与上述相同的输入执行步骤 2 或我们的作业...

使用 EMR CLI ,我们这样做:

> export jobflow=$(elastic-mapreduce --create --alive --plain-output
> --master-instance-type m1.small --slave-instance-type m1.xlarge --num-instances 21 --name "Custer Name" --bootstrap-action s3://elasticmapreduce/bootstrap-actions/configure-hadoop --args
> "--mapred-config-file,s3://myBucket/conf/custom-mapred-config-file.xml")
>
>
> elastic-mapreduce -j $jobflow --jar
> s3://us-east-1.elasticmapreduce/libs/s3distcp/1.latest/s3distcp.jar
> --arg --src --arg 's3://myBucket/input/' --arg --dest --arg 'hdfs:///input'
>
> elastic-mapreduce --jobflow $jobflow --jar s3://myBucket/bin/step1.jar
> --arg hdfs:///input --arg hdfs:///output-step1 --step-name "Step 1"
>
> elastic-mapreduce --jobflow $jobflow --jar s3://myBucket/bin/step2.jar
> --arg hdfs:///input,hdfs:///output-step1 --arg s3://myBucket/output/ --step-name "Step 2"

关于python - 如何将 EMR 流作业的输出写入 HDFS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16432660/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com