MapReduce初体验

来源:互联网 发布:詹姆斯卡梅隆,知乎 编辑:程序博客网 时间:2024/05/16 01:08

首先跑一下Hadoop自己带的world count。

先得上传文件到HDFS。

hadoop fs -mkdir -p /wordcount/inputhadoop fs -put GitHubLog.txt /wordcount/input

然后运行

hadoop jar /root/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /wordcount/input/ /wordcount/output

其中 /wordcount/output 是结果的输出目录,要求不存在。

在这一步还出了问题,结果是之前的集群没配好。之前那篇配置Hadoop的博客已经修正了。

使用下面的命令查看结果:

hadoop fs -cat /wordcount/output/part-r-00000

一部分结果是:

extracted       4failed. 2failed: 2fatal:  2fetch   1file    3file;   2filters 1find    2for     11from    4get     1git     3git.c:371       2github  1github.com      6

自己写MapReduce程序的部分的话,可以参考这一篇使用MapReduce计算Pi的文章。http://blog.csdn.net/mrbcy/article/details/61455917

0 0
原创粉丝点击