本例子统计 用空格分开的单词出现数量( 这个Main.mian 启动方式是hadoop 2.0 的写法。1.0 不一样 )
目录结构:
使用的 maven : 下面是maven 依赖。
Main.java:
WordMap.java
WordReduce.java
content.txt 是 要上传到hdfs 上作为输入参数目录的 ,内容我就不提提供了。随便找个页面复制一些文本就可以。
然后打成 jar 包。 发布到hadoop 上运行。( 后面 两个参数是 指定的 输入 和输出路径 )运行前应该吧 要统计的文件复制到 hdfs 的 /wd/in 目录里面。
运行结果:
part-r-00000 打开结果: