gpt4 book ai didi

Python hadoop mapreduce 作业使用 mrjob subprocess.CalledProcessError

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

我正在尝试在我的自定义数据上运行来自 mrjob 网站的基本示例。我已经使用流成功运行了 Hadoop map reduce,我也成功地尝试了没有 Hadoop 的脚本,但现在我正尝试通过 mrjob 在 Hadoop 上运行它,方法是执行以下命令。

./mapred.py -r hadoop --hadoop-bin /usr/bin/hadoop -o hdfs:///user/cloudera/wc_result_mrjob hdfs:///user/cloudera/books

mapred.py源码如下:

#! /usr/bin/env python

from mrjob.job import MRJob


class MRWordFrequencyCount(MRJob):

def mapper(self, _, line):
yield "chars", len(line)
yield "words", len(line.split())
yield "lines", 1

def reducer(self, key, values):
yield key, sum(values)

if __name__ == '__main__':
MRWordFrequencyCount.run()

不幸的是,我收到以下错误:

no configs found; falling back on auto-configuration
no configs found; falling back on auto-configuration
creating tmp directory /tmp/mapred.cloudera.20140824.195414.420162
writing wrapper script to /tmp/mapred.cloudera.20140824.195414.420162/setup-wrapper.sh
STDERR: mkdir: `hdfs:///user/cloudera/tmp/mrjob/mapred.cloudera.20140824.195414.420162/files/': No such file or directory
Traceback (most recent call last):
File "./mapred.py", line 18, in <module>
MRWordFrequencyCount.run()
File "/usr/lib/python2.6/site-packages/mrjob/job.py", line 494, in run
mr_job.execute()
File "/usr/lib/python2.6/site-packages/mrjob/job.py", line 512, in execute
super(MRJob, self).execute()
File "/usr/lib/python2.6/site-packages/mrjob/launch.py", line 147, in execute
self.run_job()
File "/usr/lib/python2.6/site-packages/mrjob/launch.py", line 208, in run_job
runner.run()
File "/usr/lib/python2.6/site-packages/mrjob/runner.py", line 458, in run
self._run()
File "/usr/lib/python2.6/site-packages/mrjob/hadoop.py", line 238, in _run
self._upload_local_files_to_hdfs()
File "/usr/lib/python2.6/site-packages/mrjob/hadoop.py", line 265, in _upload_local_files_to_hdfs
self._mkdir_on_hdfs(self._upload_mgr.prefix)
File "/usr/lib/python2.6/site-packages/mrjob/hadoop.py", line 273, in _mkdir_on_hdfs
self.invoke_hadoop(['fs', '-mkdir', path])
File "/usr/lib/python2.6/site-packages/mrjob/fs/hadoop.py", line 109, in invoke_hadoop
raise CalledProcessError(proc.returncode, args)
subprocess.CalledProcessError: Command '['/usr/bin/hadoop', 'fs', '-mkdir', 'hdfs:///user/cloudera/tmp/mrjob/mapred.cloudera.20140824.195414.420162/files/']' returned non-zero exit status 1

在我看来,mrjob 无法在 HDFS 中创建一些目录,但不幸的是我不知道如何解决这个问题。

我的Hadoop是cloudera CDH5.1。快速入门。

提前感谢您提出任何建议和意见。

编辑:

我曾尝试在 cloudera CDH4.7 上运行相同的代码。快速入门,效果很好。所以我修改的问题是:是cloudera CDH5.1。 mrjob框架支持吗?如果是,那么如何运行?

最佳答案

我遇到了同样的错误,我所做的解决方法是更改​​:

self.invoke_hadoop(['fs', '-mkdir', path])

self.invoke_hadoop(['fs', '-mkdir','-p', path])

修改的文件是:/usr/lib/python2.6/site-packages/mrjob/hadoop.py

我的 MRJOB 已经运行了几个月,没有任何问题,所以我觉得这很好。

我自己也很想知道同样的替代方案。

关于Python hadoop mapreduce 作业使用 mrjob subprocess.CalledProcessError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25475860/

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