1 hadoop根目录下新建存放自己编写的wordcount的文件夹:

  1.1 mkdir playground

  1.2 mkdir playground/src

  1.3 mkdir playground/classes

 

2 将编写的wordcount放到src目录下:

  

3 编译

  javac -classpath hadoop-core-1.0.3.jar:hadoop-tools-1.0.3.jar:lib/commons-cli-1.2.jar -d playground/classes playground/src/WordCount.java

 

4 打包

  jar -cvf playground/wordcount.jar -C playground/classes/ .

 

5 运行

  bin/hadoop jar playground/wordcount.jar org.apache.hadoop.examples.WordCount input output

 

over:

 

察看结果:

  bin/hadoop dfs -cat output/*