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
所以我认为这么简单的映射器和缩减器不应该给我错误,但确实如此,我不明白为什么,错误在这里:http://pastebin.com/PvY4d89c
(我在 Ubuntu16.04 的 virtualBox 上使用 Horton works HDP 沙盒)
我知道,"file not found error"和"file cannot be executed"的意思完全不同,这里的问题是文件无法执行。
在Reducer.py中:
错误:
#!usr/bin/env/ python
正确:
#!/usr/bin/env 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
所以我认为这么简单的映射器和缩减器不应该给我错误,但确实如此,我不明白为什么,错误在这里:http://pastebin.com/PvY4d89c
(我在 Ubuntu16.04 的 virtualBox 上使用 Horton works HDP 沙盒)
我知道,"file not found error"和"file cannot be executed"的意思完全不同,这里的问题是文件无法执行。
在Reducer.py中:
错误:
#!usr/bin/env/ python
正确:
#!/usr/bin/env python