【问题标题】:Hadoop MapReduce Wordcount python execution errorHadoop MapReduce Wordcount python执行错误
【发布时间】:2017-10-31 18:54:27
【问题描述】:

我正在尝试执行 python MapReduce wordcount 程序

我从writing a Hadoop MapReduce program in python 只是想了解它是如何工作的,但问题始终是 Job 不成功!

我使用Cloudera VM中的这个库执行mapper.pyreducer.py

/usr/lib/hadoop-0.20-mapreduce/contrib/streaming/hadoop-streaming-2.6.0-mr1-cdh5.12.0.jar

执行命令:

hadoop jar /usr/lib/hadoop-0.20-mapreduce/contrib/streaming/hadoop-streaming-2.6.0-mr1-cdh5.12.0.jar
-Dmaperd.reduce, tasks=1
-file wordcount/mapper.py 
-mapper mapper.py -file wordcount/reducer.py
-reducer reducer.py
-input myinput/test.txt
-output output

【问题讨论】:

  • 修复链接符合您的利益,以便用户可以参考它以更好地帮助您。
  • 错误不在这里。查看 YARN 用户界面
  • 问题出在路上,谢谢@cricket_007
  • 路径呢?随时在下面发布您的解决方案作为答案,以便其他人知道该怎么做。

标签: python hadoop mapreduce cloudera word-count


【解决方案1】:

问题出在mapper.py和reducer.py文件的路径必须来自本地

但输入文件必须来自 hdfs 路径

首先,必须使用本地测试python代码

cat <input file> | python <path from>/mapper.py | python <path from local>/reducer.py

然后在hdfs上

hadoop jar /usr/lib/hadoop-0.20-mapreduce/contrib/streaming/hadoop-streaming-2.6.0-mr1-cdh5.12.0.jar 

-Dmaperd.reduce,tasks=1 -file <path of local>/mapper.py 

-mapper "python <path from local>/mapper.py" 

-file <path from local>/reducer.py -

reducer "python <path of local>/reducer.py" 

-input <path from hdfs>/myinput/test.txt 

-output output

【讨论】:

  • 非常感谢您的解释。我被困在确切的问题上,无法弄清楚出了什么问题。
猜你喜欢
  • 1970-01-01
  • 2017-02-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-22
  • 1970-01-01
  • 2017-06-01
相关资源
最近更新 更多