Professional Documents
Culture Documents
CentOS. You are expected to know basic UNIX commands and VI editor commands.
If you are not familiar with UNIX and vi commands, you should brush up your UNIX
basics before proceeding.
2. Download CentOS iso DVD version 6.3, which is stable as on Feb 2013
http://mirrors.hns.net.in/centos/6.3/isos/x86_64/.
If you are using 32bit windows OS then you may download 32bit centos from
http://wiki.centos.org/Download
3. Run the VMware player and click on Create New Virtual Machine.
Browse to the iso downloaded in previous step.
CentOS will be installed on local system. We will be using the root user only for
installing and running Hadoop.
4. Install Java
Hadoop needs to have Java installed on your CentOS but CentOS does not come with
Oracle Java because of licensing issues. So, please use the below commands to
install java.
Download the latest java from
http://www.oracle.com/technetwork/java/javase/downloads/index.html
And it gets downloaded to Download folder of root user run the following commands.
a) rpm -Uvh /root/Downloads/jdk-7u13-linux-x64.rpmsudo apt-get update
b) alternatives --install /usr/bin/java java
/usr/java/latest/jre/bin/java 20000
c) export JAVA_HOME="/usr/java/latest"
d) Confirm the java path by running
javac version
java -version
5. Confirm your machine name
When you create a new CentOS machine, the default host name is
localhost.localdomain.
Open the /etc/hostname file with vi editor and change it if needed.
6. Configuring SSH
Hadoop requires SSH access to manage its nodes, i.e. remote machines plus your
local machine if you want to use Hadoop on it (which is what we want to do in this
short tutorial). For our single-node setup of Hadoop, we therefore need to configure
SSH access to localhost for the anil user we created in the previous section.
#Install ssh server on your computer
yum install openssh-server
ssh-keygen -t rsa -P ""
Generating public/private rsa key pair.
Enter file in which to save the key (/home/anil/.ssh/id_rsa):
Created directory '/home/anil/.ssh'.
Your identification has been saved in /home/anil/.ssh/id_rsa.
Your public key has been saved in /home/anil/.ssh/id_rsa.pub.
The key fingerprint is:
9b:82:ea:58:b4:e0:35:d7:ff:19:66:a6:ef:ae:0e:d2 root@localhost
The key's randomart image is:
[...snipp...]
The final step is to test the SSH setup by connecting to your local machine with the
anil user. The step is also needed to save your local machines host key fingerprint to
the anil users known_hosts file. If you have any special SSH configuration for your
local machine like a non-standard SSH port, you can define host-specific SSH options
in $HOME/.ssh/config (see man ssh_config for more information).
#now copy the public key to the authorized_keys file, so that ssh should not require
passwords every time
export HADOOP_HOME_WARN_SUPPRESS="TRUE"
export JAVA_HOME=/usr/java/default
9. Update $HOME/.bashrc
Add the following lines to the end of the $HOME/.bashrc file of user anil. If you use a
shell other than bash, you should of course update its appropriate configuration files
instead of .bashrc.
# Set Hadoop-related environment variables
export HADOOP_HOME=/usr/local/hadoop
# Set JAVA_HOME (we will also configure JAVA_HOME directly for Hadoop later on)
export JAVA_HOME=/usr/java/default
# Some convenient aliases and functions for running Hadoop-related commands
unalias fs &> /dev/null
alias fs="hadoop fs"
unalias hls &> /dev/null
alias hls="fs -ls"
# If you have LZO compression enabled in your Hadoop cluster and
# compress job outputs with LZOP (not covered in this tutorial):
# Conveniently inspect an LZOP compressed file from the command
# line; run via:
#
# $ lzohead /hdfs/path/to/lzop/compressed/file.lzo
#
# Requires installed 'lzop' command.
#
lzohead () {
hadoop fs -cat $1 | lzop -dc | head -1000 | less
}
# Add Hadoop bin/ directory to PATH
export PATH=$PATH:$HADOOP_HOME/bin:$PATH:$JAVA_HOME/bin
Add the following snippets between the <configuration> ... </configuration> tags in
/usr/local/hadoop/conf/core-site.xml:
<!-- In: conf/core-site.xml -->
<property>
<name>hadoop.tmp.dir</name>
<value>/app/hadoop/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:54310</value>
<description>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.</description>
</property>
12.Update mapred-site.xml file
root@localhost:~$ jps
9168
9127
8824
8714
8935
9017
Jps
TaskTracker
DataNode
NameNode
SecondaryNameNode
JobTracker