簡體   English   中英

Hadoop Streaming簡單作業失敗錯誤python

[英]Hadoop Streaming simple job fails error python

我是hadoop和mapreduce的新手,我正在嘗試編寫一個mapreduce來計算字數txt文件的前10個字數。

我的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)

我知道您可以在Hadoop jar命令中將標志傳遞給-D選項,以便對所需的鍵進行排序(在我的情況下,計數為k2,2),這里我僅使用一個簡單的命令:

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

因此,我認為這樣簡單的mapper和reducer不應給我錯誤,但確實可以,但是我不知道為什么,這里有錯誤: http : //pastebin.com/PvY4d89c

(我正在Ubuntu16.04上的virtualBox上使用Horton Works HDP Sandbox)

我知道,“找不到文件錯誤”意味着與“無法執行文件”完全不同,在這種情況下,問題是無法執行文件。

在Reducer.py中:

錯誤:

#!usr/bin/env/ python

正確:

#!/usr/bin/env python

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM