















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















Docs » HADOOP INSTALLATION
This section refers to the installation settings of Hadoop on a standalone system as well as on a system existing as a node in a cluster.
The report here will describe the required steps for setting up a single-node Hadoop cluster backed by the Hadoop Distributed File System, running on Ubuntu Linux. Hadoop is a framework written in Java for running applications on large clusters of commodity hardware and incorporates features similar to those of the Google File System (GFS) and of the MapReduce computing paradigm. Hadoop’s HDFS is a highly fault-tolerant distributed file system and, like Hadoop in general, designed to be deployed on low-cost hardware. It provides high throughput access to application data and is suitable for applications that have large data sets.
Before we start, we will understand the meaning of the following:
A DataNode stores data in the Hadoop File System. A functional file system has more than one DataNode, with the data replicated across them.
The NameNode is the centrepiece of an HDFS file system. It keeps the directory of all files in the file system, and tracks where across the cluster the file data is kept. It does not store the data of these file itself.
The Jobtracker is the service within hadoop that farms out MapReduce to specific nodes in the cluster, ideally the nodes that have the data, or atleast are in the same rack.
A TaskTracker is a node in the cluster that accepts tasks- Map, Reduce and Shuffle operatons – from a Job Tracker.
Secondary Namenode whole purpose is to have a checkpoint in HDFS. It is just a helper node for namenode.
Prerequisites
Hadoop requires a working Java 1.5+ (aka Java 5) installation.
Update the source list
user@ubuntu:~$ sudo apt‐get update
or
Install Sun Java 6 JDK
This will add the user hduser1 and the group hadoop_group to the local machine. Add hduser to the sudo group
user@ubuntu:~$ sudo adduser hduser1 sudo
The hadoop control scripts rely on SSH to peform cluster-wide operations. For example, there is a script for stopping and starting all the daemons in the clusters. To work seamlessly, SSh needs to be etup to allow password-less login for the hadoop user from machines in the cluster. The simplest ay to achive this is to generate a public/private key pair, and it will be shared across the cluster.
Hadoop requires SSH access to manage its nodes, i.e. remote machines plus your local machine. For our single-node setup of Hadoop, we therefore need to configure SSH access to localhost for the hduser user we created in the earlier.
We have to generate an SSH key for the hduser user.
user@ubuntu:~$ su – hduser hduser1@ubuntu:~$ ssh‐keygen ‐t rsa ‐P ""
The second line will create an RSA key pair with an empty password.
P “”, here indicates an empty password
You have to enable SSH access to your local machine with this newly created key which is done by the following command.
hduser1@ubuntu:~$ cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
The final step is to test the SSH setup by connecting to the local machine with the hduser1 user. The step is also needed to save your local machine’s host key fingerprint to the hduser user’s known hosts file.
export HADOOP_HOME=/usr/local/hadoop
export PATH= $PATH:$HADOOP_HOME/bin
Change the file: conf/hadoop-env.sh
#export JAVA_HOME=/usr/lib/j2sdk1.5‐sun
to in the same file
Now we create the directory and set the required ownerships and permissions
hduser@ubuntu:~$ sudo mkdir ‐p /app/hadoop/tmp hduser@ubuntu:~$ sudo chown hduser:hadoop /app/hadoop/tmp hduser@ubuntu:~$ sudo chmod 750 /app/hadoop/tmp
The last line gives reading and writing permissions to the /app/hadoop/tmp directory
Error: If you forget to set the required ownerships and permissions, you will see a java.io.IO Exception when you try to format the name node.
Paste the following between
In file conf/core-site.xml
hadoop.tmp.dir /app/hadoop/tmp A base for other temporary directories.
fs.default.name hdfs://localhost:54310 The name of the default file system. A URI whose scheme and authority determine the FileSystem implementation. The uri's scheme determines the config property (fs.SCHEME.impl) naming the FileSystem implementation class. The uri's authority is used to determine the host, port, etc. for a filesystem.
In file conf/mapred-site.xml
mapred.job.tracker localhost:54311 The host and port that the MapReduce job tracker runs at. If "local", then jobs are run in‐process as a single map and reduce task.
In file conf/hdfs-site.xml
dfs.replication 1 Default block replication. The actual number of replications can be specified when the file is created. The default is used if replication is not specified in create time.
To format the filesystem (which simply initializes the directory specified by the dfs.name.dir variable). Run the command
hduser@ubuntu:~:$ sudo rm –Rf /app/hadoop/tmp/*
hduser@ubuntu:~$ sudo netstat ‐plten | grep java
Run the command to stop all the daemons running on your machine.
hduser@ubuntu:~$ /usr/local/hadoop/bin/stop‐all.sh
If datanode is not starting, then clear the tmp folder before formatting the namenode using the following command
hduser@ubuntu:~$ rm ‐Rf /app/hadoop/tmp/*
The masters and slaves file should contain localhost. In /etc/hosts, the ip of the system should be given with the alias as localhost. Set the java home path in hadoop-env.sh as well bashrc.
MULTI-NODE INSTALLATION
Running Hadoop on Ubuntu Linux (Multi-Node Cluster)
We will build a multi-node cluster merge two or more single-node clusters into one multi-node cluster in which one Ubuntu box will become the designated master but also act as a slave , and the other box will become only a slave.
Prerequisites
Configuring single-node clusters first,here we have used two single node clusters. Shutdown each single-node cluster with the following command
user@ubuntu:~$ bin/stop‐all.sh
The hduser user on the master (aka hduser@master) must be able to connect:
Add the hduser@master public SSH key using the following command
hduser@master:~$ ssh‐copy‐id ‐i $HOME/.ssh/id_rsa.pub hduser@slave
Connect with user hduser from the master to the user account hduser on the slave.
hduser@master:~$ ssh master
hduser@master:~$ ssh slave
Hadoop
This will describe how to configure one Ubuntu box as a master node and the other Ubuntu box as a slave node.
Open this file in the conf directory
hduser@master:~/usr/local/hadoop/conf$ sudo gedit core‐site.xml
Change the fs.default.name parameter (in conf/core-site.xml), which specifies the NameNode (the HDFS master) host and port.
conf/core-site.xml (ALL machines .ie. Master as well as slave)
fs.default.name hdfs://master:54310 The name of the default file system. A URI whose scheme and authority determine the FileSystem implementation. The uri's scheme determines the config property (fs.SCHEME.impl) naming the FileSystem implementation class. The uri's authority is used to determine the host, port, etc. for a filesystem.
Open this file in the conf directory
hduser@master:~$ /usr/local/hadoop/conf hduser@master:~$ sudo gedit mapred‐site.xml
Change the mapred.job.tracker parameter (in conf/mapred-site.xml), which specifies the JobTracker (MapReduce master) host and port.
conf/mapred-site.xml (ALL machines)
mapred.job.tracker master:54311 The host and port that the MapReduce job tracker runs at. If "local", then jobs are run in‐process as a single map and reduce task.
Format the cluster’s HDFS file system
hduser@master:~/usr/local/hadoop$ bin/hadoop namenode ‐format
Starting the cluster is performed in two steps.
TaskTracker daemons are started on all slaves (here: master and slave).
Cluster is started by running the commnd on master
hduser@master:~$ /usr/local/hadoop hduser@master:~$ bin/start‐all.sh
By this command:
The NameNode daemon is started on master, and DataNode daemons are started on all slaves (here: master and slave). The JobTracker is started on master, and TaskTracker daemons are started on all slaves (here: master and slave)
To check the daemons running , run the following commands
hduser@master:~$ jps