1. 运行hadoop-1.2.1自带的wordcount example


在$hadoop_home目录生成file01, file02文本文件


将file01, file02放到hdfs的某一个目录下
bin/hadoop fs -put file01 /user/hadoop/wordcount/input
bin/hadoop fs -put file02 /user/hadoop/wordcount/input
在$hadoop_home目录执行word count的job
bin/hadoop jar hadoop-examples-1.2.1.jar wordcount /user/hadoop/wordcount/input /user/hadoop/wordcount/output
在hdfs的output目录下会生成如下的文件和文件夹

查看part-r-00000输出文件

注意事项:
1. hadoop-example-1.2.1.jar放在本地的磁盘上而不是hdfs
2. 输入文件file01, file02放在hdfs上
3. output目录事先不能在hdfs上创建,因为程序会自动在你给的路径上创建output目录,否则会报错the directory is already existed
4. input, output不能放在hdfs的根目录/上,由于权限和security的原因,否则会报错。