hadoop执行wordcount例子

1:下载hadoop。http://mirror.esocc.com/apache/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz

2:解压. tar -zxvf 

3:修改hadoop-env.sh中的JAVA_HOME配置

4:用hadoop编译wordcount

A:代码位置/soft/hadoop/src/examples/org/apache/hadoop/examples

mkdir wordcount_classes 
javac -classpath /soft/hadoop/hadoop-core-1.2.1.jar:/soft/hadoop/lib/commons-cli-1.2.jar -d wordcount_classes WordCount.java
jar -cvf /soft/hadoop/wordcount.jar -C wordcount_classes/ .

输入

vi /soft/hadoop/input/file01
vi /soft/hadoop/input/file02

Hello World Bye World

 

Hello Hadoop Goodbye Hadoop

计算

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

结果在/soft/hadoop/output文件夹内。

{下次执行要删除output的内容,要不就执行错了}

 

你可能感兴趣的:(wordcount)