Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»BIG-DATA»Hadoop – Running a Wordcount Mapreduce Example

    Hadoop – Running a Wordcount Mapreduce Example

    By RahulAugust 24, 20162 Mins Read

    This tutorial will help you to run a wordcount mapreduce example in hadoop using command line. This can be also an initial test for your Hadoop setup testing.

    Advertisement

    1. Prerequisites

    You must have running hadoop setup on your system. If you don’t have hadoop installed visit Hadoop installation on Linux tutorial.

    2. Copy Files to Namenode Filesystem

    After successfully formatting namenode, You must have start all Hadoop services properly. Now create a directory in hadoop filesystem.

    $ hdfs dfs -mkdir -p /user/hadoop/input
    

    Copy copy some text file to hadoop filesystem inside input directory. Here I am copying LICENSE.txt to it. You can copy more that one files.

    $ hdfs dfs -put LICENSE.txt /user/hadoop/input/
    

    3. Running Wordcount Command

    Now run the wordcount mapreduce example using following command. Below command will read all files from input folder and process with mapreduce jar file. After successful completion of task results will be placed on output directory.

    $ cd $HADOOP_HOME
    $ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0.jar wordcount input output
    

    4. Show Results

    First check the names of result file created under dfs@/user/hadoop/output filesystem using following command.

    $ hdfs dfs -ls /user/hadoop/output
    

    Now show the content of result file where you will see the result of wordcount. You will see the count of each word.

    $ hdfs dfs -cat /user/hadoop/output/part-r-00000
    

    mapreduce-wordcount-example

    hadoop Mapreduce wordcount
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Using HDFS Filesystem (CLI)

    Creating Directory In HDFS And Copy Files (Hadoop)

    How to Install Hadoop on Ubuntu 22.04

    How to Install Apache Hadoop on Ubuntu 22.04

    How to Install and Configure Hadoop on Ubuntu 20.04

    View 2 Comments

    2 Comments

    1. Gayathri Acharya on February 19, 2020 7:57 am

      thank you so much Rahul
      for your wonderfull guidance it worked me like a miracle

      Reply
    2. souradeep misra on November 21, 2016 9:00 am

      sir,
      I install hadoop successfully by helping your tutorial .and I input text file in /user/hadoop/input/.
      But I can’t understand where i put source code(java code) for mapreduce job.
      please help me.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • A Comprehensive Look at the Simple Mail Transfer Protocol (SMTP)
    • Understanding Basic Git Workflow: Add, Commit, Push
    • The Difference Between Git Reset –soft, –mixed, and –hard
    • Understanding the Staging Area in Git’s Workflow
    • Python Function with Parameters, Return and Data Types
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.