我是hadoop和mapreduce的新手,我正在尝试编写一个mapreduce来计算一个字数txt文件的前10位数字。Hadoop Streaming简单作业失败错误python
我的txt文件 'q2_result.txt' 的样子:
yourself 268
yourselves 73
yoursnot 1
youst 1
youth 270
youthat 1
youthful 31
youths 9
youtli 1
youwell 1
youwondrous 1
youyou 1
zanies 1
zany 1
zeal 32
zealous 6
zeals 1
映射:
#!/usr/bin/env python
import sys
for line in sys.stdin:
line = line.strip()
word, count = line.split()
print "%s\t%s" % (word, count)
减速机:
#!usr/bin/env/ python
import sys
top_n = 0
for line in sys.stdin:
line = line.strip()
word, count = line.split()
top_n += 1
if top_n == 11:
break
print '%s\t%s' % (word, count)
我知道你可以通过一个标志-D选项在Hadoop的jar命令,所以它对你想要的键进行排序(在我的情况下,计数是k2,2),在这里我只是使用一个简单的命令冷杉T:
hadoop jar /usr/hdp/2.5.0.0-1245/hadoop-mapreduce/hadoop-streaming-2.7.3.2.5.0.0-1245.jar -file /root/LAB3/mapper.py -mapper mapper.py -file /root/LAB3/reducer.py -reducer reducer.py -input /user/root/lab3/q2_result.txt -output /user/root/lab3/test_out
因此,我认为这种简单的映射,与减速机不应该给我的错误,但它确实和我想不通为什么,这里的错误:http://pastebin.com/PvY4d89c
(我使用的Horton在Ubuntu16.04上的VirtualBox上运行HDP Sandbox)
请检查了这一点http://stackoverflow.com/questions/4339788/hadoop-streaming-无法找到文件错误 – Rahmath