第一个MapReduce程序笔记

来源:互联网 发布:mysql e 执行sql 编辑:程序博客网 时间:2024/05/17 01:59

该程序是统计每个单词的使用频率
1.mapReduce程序是在hadoop官方文档上拷贝过来的,文件名为WordCount.java
2.编译打包该MapReduce程序:

$ javac -classpath ~/hadoop-1.2.1/hadoop-core-1.2.1.jar -d . WordCount.java$ jar -cvf WordCount.jar -C . .

3.将测试的文件上传到hdfs上

$ bin/hadoop fs -put file01 /usr/joe/wordcount/input$ bin/hadoop fs -put file02 /usr/joe/wordcount/input

4.运行该MapReduce程序:

$ ~/hadoop-1.2.1/bin/hadoop jar WordCount.jar WordCount /usr/joe/wordcount/input /usr/joe/wordcount/output

运行之前需要确保/usr/joe/wordcount/output是不存在的

0 0