Wednesday, March 11, 2015

Installing cdh3 on Centos


INTRODUCTION HADOOP

Apache Hadoop is a Java software framework that allows for the distributed processing of large data sets across clusters of computers spread across the world using a simpleprogramming model.
Hadoop can be configured in the following three modes:
1. Local Standalone (Non-distributed)
2. Pseudo Distributed
3. Fully Distributed



1.Install CentOS

I assume you are starting from scratch and want to setup a small cluster with minimum OS components (as far as I could minimize it). To start, download the OS setup media, and boot each machine with it. Go through the screens of the GUI installer, keeping in mind to do the following:

- Disable IP V 6 during Network setup

- De-select all components, including all GUIs and even  "Server"

- On the component selection page, click "Customize now" radio button and click next

- In "Base System" group, De-select "Dialup Networking Support"

It is important (at least in this tutorial) to define the host names in your DNS server (or in the host file, if no DNS
server is used). Be careful with the hosts file, one problem was caused by the loop back address (127.0.0.1) being assigned to the name of your host (in this case,master). Apparently Java listeners use the hostname to lookup the IP address to listen to, and they picked up the loop back address from hosts file, instead of the network address.

2.Create user

3.Firewal Configuration (IPtables & Selinux)

3.1.IPtables:

When the OS installation is complete, make sure to turn off and disable firewalls:

1.[root@PRAVEEN PRAKASAN ~]# service iptables save
2.[root@PRAVEEN PRAKASAN ~]# service iptables stop
3.[root@PRAVEEN PRAKASAN ~]# chkconfig iptables off
4.[root@PRAVEEN PRAKASAN ~]# /etc/init.d/iptables status
(Check the iptables status)
5.[root@PRAVEEN PRAKASAN ~]# service ip6tables stop
6.[root@PRAVEEN PRAKASAN ~]# chkconfig 1p6tables off
7.[root@PRAVEEN PRAKASAN ~]# /etc/init.d/ip6tables status
(Check the ip6tables status)

It may be a good idea to update your OS before installing hadoop:
1.[root@PRAVEEN PRAKASAN ~]# yum update
3.2.Firewall:

Hadoop uses a lot of ports for its internal and external communications. We've just allowed all traffic between the servers in the cluster and clients. But if you don't want to do that you can also selectively open the required ports. I try to mention them but they can all be changed in the configuration files. I might also miss some due to our config so I'd be glad if someone could point those out to me.

1.[root@PRAVEEN PRAKASAN ~]# nano /etc/selinux/config (Edit selinux=disabled) (In nano [--> crtl+X (save) press Y <--] This command working for root)
2.[root@PRAVEEN PRAKASAN ~]# /usr/sbin/sestatus      (Check the selinux)
3.[root@PRAVEEN PRAKASAN ~]# init 6 (restart the system)


4.Change Hostname:

1.[root@PRAVEEN PRAKASAN ~]# hostname master
2.[root@PRAVEEN PRAKASAN ~]# nano /etc/sysconfig/network

5.Java Installation& Configuration


5.1.Install Java



* We're using JDK 7 Update 03


You have to download the JDK from Oracle's website yourself as license issues prevent it from being added to the repositories. Chose the correct system (probably Linux x64) and make sure to download the file ending in
-rpm (i.e. jdk-7u3-linux-x64.rpm). You might have to do this from a client machine because you need a browser that works with the Oracle site. So on any one machine execute the following:


5.1.1Download



1.[root@PRAVEEN PRAKASAN ~]# mkdir /home/projecte
2.[root@PRAVEEN PRAKASAN ~]# cd /home/projecte/
3.[root@PRAVEEN PRAKASAN projecte]# wget  http://download.oracle.com/otn-


Execute the following commands:

1.[root@PRAVEEN PRAKASAN projecte]# chmod a+x jdk-7u3-linux-x64-rpm
(To change the permissions of the file)
2.[root@PRAVEEN PRAKASAN projecte]# rpm -ivh jdk-7u3-linux-x64-rpm
(If you have followed the instructions, java is installed in /usr/java/jdk1.7.0_03)

To make sure java was installed correctly:
1.[root@PRAVEEN PRAKASAN projecte]# java -version

5.2.Configure Java:

Setup some paths in the login script:

1.[root@PRAVEEN PRAKASAN ~]# nano /etc/profile/ (add the following to the end of the profile script)
=> export JAVA_HOME=/usr/java/jdk1.7.0_03
=> export PATH=${JAVA_HOME}/bin:$PATH
=> export CLASSPATH=${JAVA_HOME}/lib/tools.jar


6.Cloudera Hadoop installation:

Cloudera has now new software scm-express which make installation of hadoop and other component easier.
    You can change directory to /etc/yum.repos.d/
1.[root@PRAVEEN PRAKASAN ~]# cd /etc/yum.repos.d/
    Then get file using
2.[root@PRAVEEN PRAKASAN yum.repos.d]# wget
    After that you can update repository by typing yum update yum
3.[root@PRAVEEN PRAKASAN yum.repos.d]# yum update yum -y
    which should be able to see all new packages by typing command yum search hadoop)
5.[root@PRAVEEN PRAKASAN yum.repos.d]# yum searsh hadoop

7.Install Hadoop deamons

    On namenode (namenode only for master)
1.[root@PRAVEEN PRAKASAN ~]# yum -y install hadoop-0.20
2.[root@PRAVEEN PRAKASAN ~]# yum -y install hadoop-0.20-namenode
3.[root@PRAVEEN PRAKASAN ~]# yum -y install hadoop-0.20-jobtracker
    On secondarynamenode (secondarynamenode only for master1)
1.[root@PRAVEEN PRAKASAN ~]# yum -y install hadoop-0.20
2.[root@PRAVEEN PRAKASAN ~]# yum -y install hadoop-0.20-secondarynamenode
    On datanode (datanode for all slaves)
1.[root@PRAVEEN PRAKASAN ~]# yum -y install hadoop-0.20
2.[root@PRAVEEN PRAKASAN ~]# yum -y install hadoop-0.20-datanode
3.[root@PRAVEEN PRAKASAN ~]# yum -y install hadoop-0.20-tasktracker


8.Adding users to the hadoop group:

Add the users(hdfs and mapred) to the Hadoop group in master and slave
1.[root@master /]# sudo gpasswd -a hdfs hadoop
2.[root@master /]# sudo gpasswd -a mapred hadoop


9.Configure HDFS:

9.1.Setup some paths in the login script:

1.[root@PRAVEEN PRAKASAN ~]# nano /etc/profile
(add the following to the end of the profile script)
 export HADOOP_HOME=/usr/lib/hadoop
 export PATH=${HADOOP_HOME}/bin:${PATH}
 export HADOOP_CLASSPATH=${HADOOP_HOME}/hadoop-tools.jar
2.[root@PRAVEEN PRAKASAN ~]# ee .bash_profile
 export HADOOP_CONF=/etc/hadoop-0.20/conf
 export HADOOP_BIN=/usr/lib/hadoop/bin
 export HADOOP_CORE=/etc/hadoop-0.20/conf/core-site.xml
 export HADOOP_HDFS=/etc/hadoop-0.20/conf/hdfs-site.xml
 export HADOOP_MAPRED=/etc/hadoop-0.20/conf/mapred-siite.xml
 export HADOOP_ENV=/etc/hadoop-020/conf/hadoop-env.sh
 export HADOOP_LOGS=/var/logs/hadoop
 export HADOOP_STORE=/home/hadoop/ 

9.2.Modify the /etc/hadoop-0.20/conf/hadoop-env.sh:

1.[root@PRAVEEN PRAKASAN ~]# nano /etc/hadoop-0.20/conf/hadoop-env.sh
(Find the following exports and modify them accordingly:)
 export JAVA_HOME=/usr/java/jdk1.7.0_03
 export HADOOP_OPTS=-Djava.net.preferIPv4Stack=true
 export HADOOP_PID_DIR=${HADOOP_HOME}/tmp/pids
 export HADOOP_NAMENODE_USER=hdfs
 export HADOOP_DATANODE_USER=hdfs
 export HADOOP_SECONDARYNAMENODE_USER=hdfs
 export HADOOP_JOBTRACKER_USER=mapred
 export HADOOP_TASKTRACKER_USER=mapred

9.3.Hadoop configuration deafault-site.xml file


1.conf/core-site.xml

1.[root@PRAVEEN PRAKASAN ~]# ee $HADOOP_CORE

<!-- In: conf/core-site.xml -->
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>${HADOOP_STORE}/tmp</value>
</property>
<property>
<name>fs.default.name</name>
<value>www.hdfs.com:8020</value>
</property>
</configuration>

2.conf/hdfs-site.xml
1.[root@PRAVEEN PRAKASAN ~]# ee $HADOOP_HDFS

- In: conf/hdfs-site.xml -->
<configuration>

<property>
<name>dfs.namenode.plugins</name>
<value>org.apache.hadoop.thriftfs.NamenodePlugin</value>
<description>
Comma-separated list of namenode plug-ins to be activated.
</description>
</property>
<property>
<name>dfs.datanode.plugins</name>
<value>org.apache.hadoop.thriftfs.DatanodePlugin</value>
<description>
Comma-separated list of datanode plug-ins to be activated.
</description>
</property>
<property>
<name>dfs.thrift.address</name>
<value>0.0.0.0:9090</value>
</property>
<property>
<name>dfs.permissions</name>
<value>true</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>${HADOOP_STORE}/datastore/name</value>
<final>true</final>
</property>
<property>
<name>fs.checkpoint.dir</name>
<value>${HADOOP_STORE}/dfs/namesecondary</value>
<final>true</final>
</property>
<property>
<name>dfs.data.dir</name>
<value>${HADOOP_STORE}/datastore/data</value>
<final>true</final>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>


<configuration>

3.conf/mapred-site.xml

1.[root@PRAVEEN PRAKASAN ~]# ee $HADOOP_MAPRED



<!-- In: conf/mapred-site.xml -->
<configuration>
<!-- Enable Cloudera Desktop plugins
<property>
<name>mapred.jobtracker.plugins</name>
<value>org.apache.hadoop.thriftfs.ThriftJobTrackerPlugin</value>
<description>
Comma-separated list of jobtracker plug-ins to be activated.
</description>
</property>
<property>
<name>mapred.job.tracker</name>
<value>www.hdfs.com:8021</value>
</property>
<property>
<name>mapred.system.dir</name>
<value>${HADOOP_STORE}/taskstore/system</value>
<final>true</final>
</property>
<property>
<name>mapred.local.dir</name>
<value>${HADOOP_STORE}/taskstore/mapred</value>
<final>true</final>
</property>
<property>
<name>mapred.tasktracker.map.tasks.maximum</name>
<value>4</value>
</property>
<property>
<name>mapred.tasktracker.reduce.tasks.maximum</name>
<value>4</value>
</property>
<property>
<name>mapred.userlog.retain.hours</name>
<value>8</value>
</property>
    <configuration>


10.Create Hadoop Diractory & permissions:

1.[root@PRAVEEN PRAKASAN ~]# mkdir -p $HADOOP_STORE/tmp
2.[root@PRAVEEN PRAKASAN ~]# chmod 750 $HADOOP_STORE/tmp
3.[root@PRAVEEN PRAKASAN ~]# chwon hdfs:hadoop $HADOOP_STORE/tmp

4.[root@PRAVEEN PRAKASAN ~]# mkdir -p $HADOOP_STORE/datastore
5.[root@PRAVEEN PRAKASAN ~]#  chmod 775 $HADOOP_STORE/datastore

6.[root@PRAVEEN PRAKASAN ~]# chown hdfs:hadoop $HADOOP_STORE/datastore

7.[root@PRAVEEN PRAKASAN ~]# mkdir -p $HADOOP_STORE/datastore/name
8.[root@PRAVEEN PRAKASAN ~]# chown -R hdfs $HADOOP_STORE/datastore/name

9.[root@PRAVEEN PRAKASAN ~]# mkdir -p $HADOOP_STORE/datastore/data
10.[root@PRAVEEN PRAKASAN ~]# chown -R hdfs $HADOOP_STORE/datastore/data

11.[root@PRAVEEN PRAKASAN ~]# mkdir -p $HADOOP_STORE/taskstore
12.[root@PRAVEEN PRAKASAN ~]# chmod 775 $HADOOP_STORE/taskstore
13.[root@PRAVEEN PRAKASAN ~]# chown mapred:hadoop $HADOOP_STORE/taskstore

14.[root@PRAVEEN PRAKASAN ~]# mkdir -p $HADOOP_STORE/taskstore/system
15.[root@PRAVEEN PRAKASAN ~]# chown -R hdfs $HADOOP_STORE/taskstore/system

16.[root@PRAVEEN PRAKASAN ~]# mkdir -p $HADOOP_STORE/taskstore/mapred
17.[root@PRAVEEN PRAKASAN ~]# chmod 755 $HADOOP_STORE/taskstore/mapred
18.[root@PRAVEEN PRAKASAN ~]# chown mapred:hadoop $HADOOP_STORE/taskstore/mapred

19.[root@PRAVEEN PRAKASAN ~]# mkdir -p $HADOOP_STORE/tmp/pids
20.[root@PRAVEEN PRAKASAN ~]# chown -R hdfs $HADOOP_STORE/tmp/pids

11.IP hosts configuration
Edit the /etc/hosts:
1.[root@PRAVEEN PRAKASAN ~]# nano /etc/hosts
(add the master and slaves ip and hostname like this)
192.168.1.2
master
192.168.1.3
slave0
192.168.1.4
slave1


12.Define the masters and slaves (Only on master node):

1.[root@PRAVEEN PRAKASAN ~]# nano $HADOOP_CONF/masters

    In this case hostname of master
    master
    Now modify the slaves file:
2.[root@PRAVEEN PRAKASAN ~]#nano $HADOOP_CONF/slaves
    Slaves in our example are slave0 and slave1:
    slave0
    slave1

 13.TO Configure Slaves_Datanode

14.Run Hadoop Cluster

14.1.NameNode Format

1.[hdfs@PRAVEEN PRAKASAN ~]# sudo –u hdfs $HADOOP_HOME/bin/hadoop namenode -format

 4.2.Deamons Run Command
1.[hdfs@PRAVEEN PRAKASAN ~]# start-all.sh
OR
1.[hdfs@PRAVEEN PRAKASAN ~]# start-dfs.sh
2.[mapred@PRAVEEN PRAKASAN ~]# start-mapred.sh
OR
1.[root@PRAVEEN PRAKASAN ~]# sudo -u hdfs /usr/lib/hadoop/bin/hadoop namenode
2.[root@PRAVEEN PRAKASAN ~]# sudo -u hdfs /usr/lib/hadoop/bin/hadoop secondarynamenode
3.[root@PRAVEEN PRAKASAN ~]# sudo -u hdfs /usr/lib/hadoop/bin/hadoop datanode
4.[root@PRAVEEN PRAKASAN ~]# sudo -u mapred /usr/lib/hadoop/bin/hadoop jobtracker
5.[root@PRAVEEN PRAKASAN ~]# sudo -u mapred /usr/lib/hadoop/bin/hadoop tasktracker
OR
1.[root@PRAVEEN PRAKASAN ~]# service hadoop-0.20-namenode start
2.[root@PRAVEEN PRAKASAN ~]# service hadoop-0.20-secondarynamenode start
3.[root@PRAVEEN PRAKASAN ~]# service hadoop-0.20-datanode start
4.[root@PRAVEEN PRAKASAN ~]# service hadoop-0.20-tasktracker start
5.[root@PRAVEEN PRAKASAN ~]# service hadoop-0.20-jobtracker start
OR
1.[root@PRAVEEN PRAKASAN ~]# /etc/init.d/hadoop-0.20-namenode start
2.[root@PRAVEEN PRAKASAN ~]# /etc/init.d/hadoop-0.20-secondarynamenode start
3.[root@PRAVEEN PRAKASAN ~]# /etc/init.d/hadoop-0.20-datanode start
4.[root@PRAVEEN PRAKASAN ~]# /etc/init.d/hadoop-0.20-tasktracker start
5.[root@PRAVEEN PRAKASAN ~]# /etc/init.d/hadoop-0.20-jobtracker start



15.MapReduce For Example

1.[root@PRAVEEN PRAKASAN ~]# cd  $HADOOP_HOME
2.[root@PRAVEEN PRAKASAN ~]#bin/hadoop jar hadoop-example.jar sleep –m 10 -r 10 -mt 10 -rt 10
-record 10