首先跑一下Hadoop自己带的world count。
先得上传文件到HDFS。
hadoop fs -mkdir -p /wordcount/input
hadoop 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 4
failed. 2
failed: 2
fatal: 2
fetch 1
file 3
file; 2
filters 1
find 2
for 11
from 4
get 1
git 3
git.c:371 2
github 1
github.com 6
自己写MapReduce程序的部分的话,可以参考这一篇使用MapReduce计算Pi的文章。http://blog.csdn.net/mrbcy/article/details/61455917