本文主要是介绍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的内容,要不就执行错了}
这篇关于hadoop执行wordcount例子的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!