我是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