一般可以在linux下可以进行测试操作
cat inputfile | python mapper.py | sort | python reducer.py > outputfile
单词统计 WordCount
制作一个mapReduce操作需要一个map.py 和 reduce.py
map.py
import sys
for line in sys.stdin:
line_words = line.strip().split(' ')
for word in line_words:
print '%s\t1'%(word.strip())
reduce.py
import sys
cur_word = None
sum = 0
for line in sys.stdin:
word,count = line.strip().split('\t')
try:
count = int

本文介绍了如何使用Python在Linux环境下进行Hadoop MapReduce的WordCount实例,详细阐述了map.py和reduce.py的实现,并讲解了如何为hadoop-streaming-2.6.5.jar添加执行权限以及运行MapReduce任务。同时,讨论了Hadoop的常用配置,包括调整reduce数量、设置节点白名单和执行多任务结合操作。
最低0.47元/天 解锁文章
344

被折叠的 条评论
为什么被折叠?



