SapHanaTutorial.Com HOME     Learning-Materials Interview-Q&A Certifications Quiz Online-Courses Forum Jobs Trendz FAQs  
     Explore The World of Hana With Us     
About Us
Contact Us
 Apps
X
HANA App
>>>
Hadoop App
>>>
Tutorial App on SAP HANA
This app is an All-In-One package to provide everything to HANA Lovers.

It contains
1. Courses on SAP HANA - Basics, Modeling and Administration
2. Multiple Quizzes on Overview, Modelling, Architeture, and Administration
3. Most popular articles on SAP HANA
4. Series of Interview questions to brushup your HANA skills
Tutorial App on Hadoop
This app is an All-In-One package to provide everything to Hadoop Lovers.

It contains
1. Courses on Hadoop - Basics and Advanced
2. Multiple Quizzes on Basics, MapReduce and HDFS
3. Most popular articles on Hadoop
4. Series of Interview questions to brushup your skills
Apps
HANA App
Hadoop App
';
Search
Stay Connected
Search Topics
Course Index
Close
X
Install Your Own Hadoop on Windows and Run MapReduce Programs
Course Overview
1. Introduction
2. Installation of Hadoop 1.0
3. MapReduce Programs in Hadoop 1.0
4. Installation of Hadoop 2.0
5. MapReduce Programs in Hadoop 2.0
6. What is Next?
<< Previous
Next >>
5.2. Run MapReduce Programs

We have already started NameNode, DataNode, Resource Manager and Node Manager and now we are ready to execute Hadoop MapReduce job in the Single Node (pseudo-distributed mode) cluster.

Find Word Count of a file:
We will run wordcount MapReduce job available in %HADOOP_HOME%\share\hadoop\mapreduce\hadoop-mapreduce-examples-2.2.0.jar to count number of words in input file.

Hadoop Installation on Windows

    1. Create a directory in HDFS by executing following command
      hdfs dfs -mkdir -p InputDir

      You would observe that in Hadoop File system, new directory has been created.

      Hadoop Installation on Windows

    2. Create some text file(say 'SampleInput.txt') in local disk with some content written in it.
      We will copy this file to the newly created 'input' directory in HDFS by executing following command.
      hdfs dfs -copyFromLocal C:/SampleInput.txt InputDir

      You would observe that file is present in Hadoop file system.

      Hadoop Installation on Windows

    3. Next step would be to run wordcount MapReduce job provided in %HADOOP_HOME%\share\hadoop\mapreduce\hadoop-mapreduce-examples-2.2.0.jar.
      Execute command
      yarn jar "C:/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar wordcount InputDir OutputDir

      InputDir is the directory in file system where SAmpleInput.txt file is present. Above wordcount program will process the number of words in the file and store them in output file OutputDir
    4. You can see that new Job is created to perform this task, Job can be tracked in the NodeManager web interface.

      Hadoop Installation on Windows

    5. Let’s check if wordcount MapReduce application has successfully done its task by checking the content of OutputDir file. Execute command
      hdfs dfs -cat OutputDir/*

      You should see similar output like below which will show the frequency of each word in the input file.

      Hadoop Installation on Windows



Find Word Median (median length of the words) in a file:
Let’s try one more program of Hadoop Examples jars that counts the median length of the words in the input files.
    1. We can use the same file (SampleInput.txt ) which we have uploaded in HDFS as the part of the first program.
    2. Execute the below command
      c:\hadoop\bin>yarn jar "C:\hadoop\share\hadoop\mapreduce\hadoop-mapreduce-examples-2.2.0.jar" wordmedian InputDir OututDirWordMean


      Here we are telling that take the files present in InputDir directory (remember its already loaded into Hadoop File system) as an Input to this MapReduce program wordmedian and store the output to the new directory OututDirWordMean in HDFS.

      Hadoop Installation on Windows

    3. You will see the output as below after completion of the job

      Hadoop Installation on Windows

      In this case, the output is 4.
    4. You can also execute command to check the content of newly created file which contains results of wordmedian program
      hdfs dfs -cat OutputDirWordMean

When you’re done, stop the daemons with below command
bin/stop-all.sh

<< Previous
Next >>

Leave a Reply

Your email address will not be published. Required fields are marked *

Current day month ye@r *

 © 2017 : saphanatutorial.com, All rights reserved.  Privacy Policy