Hadoop Map/Reduce 示例程序WordCount
#进入hadoop安装目录
cd /usr/local/hadoop
#创建示例文件:input
#在里面输入以下内容:
#Hello world, Bye world!
vim input
#在hdfs上创建文件路径
bin/hadoop fs -mkdir /user/root/test/wordcount
#将输入文件拷贝到hdfs
bin/hadoop fs -put input /user/root/test/wordcount
#执行程序
bin/hadoop jar hadoop-examples-1.0.3.jar wordcount /user/root/test/wordcount /user/root/test/wordcount/output
#程序在执行完毕后查看执行结果
bin/hadoop fs -cat /user/root/test/wordcount/output/*
#程序将会输出下面的结果(请忽略最后一句^_^):
Bye 1
Hello 1
world! 1
world, 1
cat: File does not exist: /user/root/test/wordcount/output/_logs
#至此,map/reduce执行完毕。
////////////////////////////////
////////Sixi. Let it be.../////
//////////////////////////////