zoukankan      html  css  js  c++  java
  • 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结果:

      

  • 相关阅读:
    前端(基础篇)
    面向对象
    python(进阶篇)
    Python(基础篇)
    pycharm中添加python3 的环境变量
    MySQL与MongoDB的不同
    pycharm中添加python3 的环境变量
    ContentType&CORS&Git
    RESTful 组件
    Django REST_framework Quickstart
  • 原文地址:https://www.cnblogs.com/qj4d/p/7106783.html
Copyright © 2011-2022 走看看