hadoop分布式集群部署以及过程中遇到的一些坑

在hadoop学习过程中,首先第一步是部署伪分布以及分布式集群。
在集群的部署过程中http://www.powerxing.com/install-hadoop-cluster/
使用这篇博客作为参考。

创新互联建站-专业网站定制、快速模板网站建设、高性价比绛县网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式绛县网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖绛县地区。费用合理售后完善,十载实体公司更值得信赖。

在部署过程中。 遇到一些问题。
比如:用PYTHON 跑一个简单的MAPREDUCE 任务,首先需要现在streamingJAR包,简单的说这个包封装了一些常用的接口,PYTHON 通过标准输入输出来调用这个包。最终完成在内部用JAVA实现的功能。
下载地址为:http://www.java2s.com/Code/JarDownload/hadoop-streaming/

python 程序为 mapper.py

#!/usr/bin/env python
import sys
for line in sys.stdin:
line = line.strip()
words = line.split()
for word in words:
print "%s\t%s" % (word, 1)

以及reducer.py

**#!/usr/bin/env python
from operator import itemgetter
import sys

current_word = None
current_count = 0
word = None

for line in sys.stdin:
line = line.strip()
word, count = line.split('\t', 1)
try:
count = int(count)
except ValueError: #count如果不是数字的话,直接忽略掉
continue
if current_word == word:
current_count += count
else:
if current_word:
print "%s\t%s" % (current_word, current_count)
current_count = count
current_word = word

if word == current_word: #不要忘记最后的输出
print "%s\t%s" % (current_word, current_count)**

    运行方式:
hadoop jar ./hadoop-streaming-2.6.0.jar -file ./mappper.py -file ./reducer.py  -input /input -output /output

这里需要注意的是  /input 必须放在hadoop文件系统上
hadoop fs -put input /input 
/output 不能存在,如果存在请先删除

另外在python中首行必须写   #!/usr/bin/env python
否则可能会报错。具体原因可以看http://andylue2008.iteye.com/blog/1622260  这篇博客

另外如果使用hadoop fs -ls 这样的命令报错: 找不到ls目录。是因为没有创建家目录
hadoop fs -mkdir -p /user/hadoop

文章标题:hadoop分布式集群部署以及过程中遇到的一些坑
文章起源:https://www.cdcxhl.com/article22/igpojc.html

成都网站建设公司_创新互联,为您提供网站改版关键词优化品牌网站建设静态网站网站排名

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网页设计公司