Hadoop wordcount Demon

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hadoop wordcount Demon相关的知识,希望对你有一定的参考价值。

  搭建完成Hadoop后,第一个demon,wordcount。此处参考:http://blog.csdn.net/wangjia55/article/details/53160679

  wordcount是hadoop的入门经典.

  1.在某个目录下新建若干文件,我在各个文件里都添加了一些英文文章段落:

  技术分享

  2.在hadoop-2.7.3目录下创建一个wordcountTest目录:

  bin/hdfs dfs -mkdir /wordcountTest

  技术分享  

  查看刚才建立的目录:

  bin/hdfs dfs -ls /

  技术分享

  可以发现,已经建立起了wordcountTest目录。

  3.将步骤1中本地的text文件上传到hdfs中:

  bin/hdfs dfs -put /home/hadoop/hadoop-2.7.3/hadoop_test/*.txt /wordcountTest

   查看上传结果:

  bin/hdfs dfs -ls /wordcountTest

   技术分享

  显示上传已完成。

  4.运行wordcount

   bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /wordcountTest/*.txt /wordcountTest/out.txt

   运行结果截图:

  技术分享

  查看运行结果:

   bin/hdfs dfs -ls /wordcountTest/out.txt/

  技术分享

  其中运行结果存储在part-r-00000中。

  查看part-r-00000文件内容:

   bin/hadoop fs -cat /wordcountTest/out.txt/part-r-00000

   截图是部分wordcount结果:

  技术分享

以上是关于Hadoop wordcount Demon的主要内容,如果未能解决你的问题,请参考以下文章

Hadoop中WordCount代码-直接加载hadoop的配置文件

hadoop之WordCount源代码分析

如何运行自带wordcount-Hadoop2

hadoop 学习笔记-2wordcount 完整实例

大数据wordcount代码。要理解代码就要配合图形理解

Hadoop:WordCount分析