Wednesday, October 16, 2013

Steps to install Hadoop 2.2.0 Stable release (Single Node Cluster)

Steps to install Hadoop 2.2.0 release (Yarn) on single node cluster setup

1. Prerequisites:

  1. Java 6
  2. Dedicated unix user(hadoop) for hadoop
  3. SSH configured
  4. hadoop 2.x tarball ( hadoop-2.2.0.tar.gz )

Lazy ?? : Check this install-hadoop


$ tar -xvzf hadoop-2.2.0.tar.gz
$ mv hadoop-2.2.0 /home/hadoop/yarn/hadoop-2.2.0
$ cd /home/hadoop/yarn
$ sudo chown -R hadoop:hadoop hadoop-2.2.0
$ sudo chmod -R 755 hadoop-2.2.0

3. Setup Environment Variables in .bashrc (optional)

# Setup for Hadoop 2.0 .

export HADOOP_HOME=$HOME/yarn/hadoop-2.2.0
export HADOOP_MAPRED_HOME=$HOME/yarn/hadoop-2.2.0
export HADOOP_COMMON_HOME=$HOME/yarn/hadoop-2.2.0
export HADOOP_HDFS_HOME=$HOME/yarn/hadoop-2.2.0
export YARN_HOME=$HOME/yarn/hadoop-2.2.0
export HADOOP_CONF_DIR=$HOME/yarn/hadoop-2.2.0/etc/hadoop

After Adding these lines at bottom of the .bashrc file
$ source .bashrc

4. Create Hadoop Data Directories

# Two Directories for name node and datanode .

$ mkdir -p $HOME/yarn/yarn_data/hdfs/namenode
$ mkdir -p $HOME/yarn/yarn_data/hdfs/datanode

5. Configuration

# Base Directory .

$ vi etc/hadoop/yarn-site.xml
Add the following contents inside configuration tag
# etc/hadoop/yarn-site.xml .

$ vi etc/hadoop/core-site.xml
Add the following contents inside configuration tag
# etc/hadoop/core-site.xml .




$ vi etc/hadoop/hdfs-site.xml
Add the following contents inside configuration tag
# etc/hadoop/hdfs-site.xml .













$ vi etc/hadoop/mapred-site.xml
If this file does not exist, create it and paste the content provided below:
# etc/hadoop/mapred-site.xml .

<?xml version="1.0"?>







6. Format namenode(Onetime Process)

# Command for formatting Name node.

$ bin/hadoop namenode -format

7. Starting HDFS processes and Map-Reduce Process

# HDFS(NameNode & DataNode).

$ sbin/ start namenode
$ sbin/ start datanode
# MR(Resource Manager, Node Manager & Job History Server).

$ sbin/ start resourcemanager
$ sbin/ start nodemanager
$ sbin/ start historyserver

 8. Verifying Installation

$ jps
# Console Output.

22844 Jps
28711 DataNode
29281 JobHistoryServer
28887 ResourceManager
29022 NodeManager
28180 NameNode

Running Word count Example Program

$ mkdir input
$ cat > input/file
This is word count example
using hadoop 2.2.0
Add input directory to HDFS:
$ bin/hadoop hdfs -copyFromLocal input /input
Note : If hdfs shows error use dfs instead
Run wordcount example jar provided in HADOOP_HOME:
$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar wordcount /input /output
Check the output at web interface
Browse HDFS dir for /output folder

8. Verifying Installation

# Commands.

$ sbin/ stop namenode
$ sbin/ stop datanode
$ sbin/ stop resourcemanager
$ sbin/ stop nodemanager
$ sbin/ stop historyserver


  1. Hi Naveen,

    Thanks for the installation details. I followed the steps set but when I invoked the command
    bin/hadoop hdfs -copyFromLocal input /input I obtained the following error
    "Error: Could not find or load main class hdfs"
    In as subsequent step I also appended all the jar directories to the HADOOP_CLASSPATH variable but that didn't help.
    Any idea what causes this?
    However when I used the deprecated command
    "hadoop dfs -copyFromLocal input /input" the input directory was copied over to the HDFS.

    1. Try put command ("hadoop hdfs -put input /input" )
      From which directory you have executing the first command ?

    2. Hi Naveen,

      Thanks for your reply.
      I executed the command from my $HOME directory because it have appended the bin directory where hadoop is residing to my PATH env. variabele. As a test, I removed the bin directory from my $PATH variable but that didn't help. Thanks,

  2. @W
    I had the same error as you, and think this might be a version/deprecation issue: hadoop hdfs is not the way to setup/load the hdfs store now. You use the hdfs script now:

    hdfs dfs -copyFromLocal input /input

    This got things going for me, and the example worked too.

  3. By the way, thanks Naveen for this guide. I'd been struggling getting hadoop running after successfully compiling from the source. There appears to be no published steps on what to do to finish the install, and it's complicated (/etc/conf files everywhere, lots of hadoop exes all over the place, no libexec directories specified etc. etc.). I downloaded the compiled hadoop-2.2.0 with its /bin, /sbin etc. all set up, and was able to get things going with your instructions. Thanks again.

  4. Hai Naveen,

    Thanks for the post. With the help of your post i'm able to configure a single node cluster successfully. It work's fine

  5. everything is going right with me.....but i am getting problem after submitting the job...that is after http://localhost:50070 i am not getting my output.....and also the link provided during job submitting saying you can see job progress here://some link//...the job progress neither start nor what is this?? can you help me...

    1. Are u getting error in word count MR code or your own MR class ? And can you explain the steps to reproduce

  6. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating Big data online training Hyderabad