Ich bin neu bei hadoop und mapreduce, ich versuche, eine mapreduce zu schreiben, die die Top 10 zählt Wörter einer Wortzahl txt-Datei zählt.Hadoop Streaming einfacher Job fehlschlägt Fehler Python
Meine txt-Datei 'q2_result.txt' wie folgt aussieht:
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
Mapper:
#!/usr/bin/env python
import sys
for line in sys.stdin:
line = line.strip()
word, count = line.split()
print "%s\t%s" % (word, count)
Reducer:
#!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)
Ich weiß, dass Sie eine Flagge passieren kann :-D Option in Hadoop jar Befehl, so dass es nach dem gewünschten Schlüssel sortiert (in meinem Fall die Anzahl, die k2,2 ist), hier verwende ich einfach einen einfachen Befehl Tannen 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
Also dachte ich solche einfachen Mapper und Minderer sollte mir Fehler nicht geben, aber es tat, und ich kann nicht herausfinden, warum Fehler hier: http://pastebin.com/PvY4d89c
(Ich bin mit der Horton arbeitet HDP Sandbox auf einer virtuellen Box auf Ubuntu16.04)
Bitte check this out http://stackoverflow.com/questions/4339788/hadoop-streaming- unable-find-file-error – Rahmath