• No results found

Practical_9_Hadoop_Linux.pdf

N/A
N/A
Protected

Academic year: 2020

Share "Practical_9_Hadoop_Linux.pdf"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

Practical: 9

Submitted By:

AIM:

HADOOP IMPLEMENTATION

IN LINUX

GANPAT UNIVERSITY

U. V. Patel College of Engineering

(2)

HADOOP

Hadoop is an Apache open source framework written in java that allows distributed processing of large datasets across clusters of computers using simple programming models. A Hadoop frame-worked application works in an environment that provides distributed storage and computation across clusters of computers. Hadoop is designed to scale up from single server to thousands of machines, each offering local computation and storage.

HADOOP ARCHITECTURE

Hadoop Common: These are Java libraries and utilities required by other Hadoop modules. These libraries provides filesystem and OS level abstractions and contains the necessary Java files and scripts required to start Hadoop.

Hadoop YARN: This is a framework for job scheduling and cluster resource management. Hadoop Distributed File System (HDFS™): A distributed file system that provides

high-throughput access to application data.

Hadoop MapReduce: This is YARN-based system for parallel processing of large data sets

MapReduce

Hadoop MapReduce is a software framework for easily writing applications which process big amounts of data in-parallel on large clusters (thousands of nodes) of commodity hardware in a reliable, fault-tolerant manner.

The term MapReduce actually refers to the following two different tasks that Hadoop programs perform: ● The Map Task: This is the first task, which takes input data and converts it into a set of data,

where individual elements are broken down into tuples (key/value pairs).

(3)

Typically both the input and the output are stored in a file-system. The framework takes care of scheduling tasks, monitoring them and re-executes the failed tasks.

The MapReduce framework consists of a single master JobTracker and one slave TaskTracker per cluster-node. The master is responsible for resource management, tracking resource

consumption/availability and scheduling the jobs component tasks on the slaves, monitoring them and re-executing the failed tasks. The slaves TaskTracker execute the tasks as directed by the master and provide task-status information to the master periodically.

The JobTracker is a single point of failure for the Hadoop MapReduce service which means if JobTracker goes down, all running jobs are halted

Hadoop Distributed File System (HDFS)

The Hadoop Distributed File System (HDFS) is based on the Google File System (GFS) and provides a distributed file system that is designed to run on large clusters (thousands of computers) of small computer machines in a reliable, fault-tolerant manner.

HDFS uses a master/slave architecture where master consists of a single NameNode that manages the file system metadata and one or more slave DataNodes that store the actual data.

A file in an HDFS namespace is split into several blocks and those blocks are stored in a set of

DataNodes. The NameNode determines the mapping of blocks to the DataNodes. The DataNodes takes care of read and write operation with the file system. They also take care of block creation, deletion and replication based on instruction given by NameNode.

How Does Hadoop Work?

Stage 1

A user/application can submit a job to the Hadoop (a hadoop job client) for required process by specifying the following items:

1. The location of the input and output files in the distributed file system.

2. The java classes in the form of jar file containing the implementation of map and reduce functions.

3. The job configuration by setting different parameters specific to the job.

Stage 2

The Hadoop job client then submits the job (jar/executable etc) and configuration to the JobTracker which then assumes the responsibility of distributing the software/configuration to the slaves, scheduling tasks and monitoring them, providing status and diagnostic information to the job-client.

Stage 3

(4)

Advantages of Hadoop

● Hadoop framework allows the user to quickly write and test distributed systems. It is efficient, and it automatic distributes the data and work across the machines and in turn, utilizes the underlying parallelism of the CPU cores.

● Hadoop does not rely on hardware to provide fault-tolerance and high availability (FTHA), rather Hadoop library itself has been designed to detect and handle failures at the application layer. ● Servers can be added or removed from the cluster dynamically and Hadoop continues to operate

without interruption.

● Another big advantage of Hadoop is that apart from being open source, it is compatible on all the platforms since it is Java based

Configuration of Hadoop File System (HDFS) on a

single-node cluster:

Step 1: Installing JAVA in your system

sudo apt-get update

sudo apt-get install openjdk-7-jdk

Check java version

Step 2: Add hadoop group and add a hduser (hadoop user)

$ sudo addgroup hadoop

$ sudo adduser --ingroup hadoop hduser

Step 3:

Configuring SSH Server:

$ ssh-keygen -t rsa -P ""

(5)

Check ssh in localhost:

$ Ssh localhost

Step 4: Disable IPV6

Virat@virat-Aspire-5750G:~$ sudo gedit /etc/sysctl.conf

Add this lines at last in file

# disable ipv6

net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1

You can check whether IPv6 is enabled on your machine with the following . A return value of 0 means IPv6 is enabled, a value of 1 means disabled (that’s what we want).

$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6

Step 5: INSTALLATION of Hadoop

Download Hadoop from the Apache Download Mirrors and extract the contents of

the Hadoop package to a location of your choice. I picked

/usr/local/hadoop

. Make sure to change the owner of all the files to the

hduser

user

and

hadoop

group, for example:

$cd /usr/local/hadoop

$ sudo tar xzf hadoop-2.7.2.tar.gz

$ sudo mv hadoop-2.7.2 hadoop

(6)

Step 6:Editing bashrc file

Add following line to ~/.bashrc file. To set path of hadoop and java

hduser@virat-Aspire-5750G:~$ vi ~/.bashrc

Check hadoop :

$Hadoop version

Step 7: Editing Configuration files

$cd /usr/local/hadoop/hadoop-2.7.2/etc/hadoop

$vi hadoop-env.sh

Add following lines to hadoop-env.sh

# The java implementation to use.

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-i386

Add the following snippets between the

<configuration> ... </configuration>

tags in the respective configuration XML file.

$vi 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>

(7)

determine the host, port, etc. for a filesystem.</description> </property>

$ vi mapred-site.xml.template

<property>

<name>mapred.job.tracker</name> <value>localhost:54311</value>

<description>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. </description> </property>

$vi hdfs-site.xml

<property>

<name>dfs.replication</name> <value>1</value>

<description>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.

</description> </property>

Step 7:

Formatting the HDFS filesystem via the NameNode

$ /usr/local/hadoop/hadoop2.7.2/bin/hadoop namenode

-format

Step 8: Starting your single-node cluster

hduser@virat-Aspire-5750G:/usr/local/hadoop/hadoop-2.7.2$

sbin/start-all.sh

(8)

Step 10:Stopping your single-node cluster

hduser@virat-Aspire-5750G:/usr/local/hadoop/hadoop-2.7.2$

sbin/stop-all.sh

Running a MapReduce job

hduser@virat-Aspire-5750G:/usr/local/hadoop/hadoop-2.7.2$

sbin/start-all.sh

//create input directory

$hadoop dfs -mkdir -p /user/hduser/input

//create output directory

$HADOOP_HOME/bin/hdfs dfs -mkdir /user/hduser/output

//put files in input

$hadoop fs -put /input/*.txt /user/hduser/input

$hadoop fs -put /input /user/hduser/input

//see input directory

$bin/hadoop dfs -ls /user/hduser/input

//run mapReduce job

(9)

//part-r-00000 contains output

//see output

bin/hadoop dfs -cat /user/hduser/output/part-r-00000

Useful Commands:

//delete files from output

$hadoop fs -rm -r /user/hduser/output

//run another mapreduce program

$bin/hadoop jar

$HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount /user/hduser/input

/user/hduser/output

Download Hadoop e Apache Download Mirrors

References

Related documents

After Day, in the lighting of Moon Night wakens under a prayer to call hush to Day, time to commune. with Night, windswept under

Therefore, many efforts have been devoted to solve most optimal Job Shop Scheduling Problems (JSSP), as most of the researches aimed at minimizing the maximum completion time. JSSP

The projected gains over the years 2000 to 2040 in life and active life expectancies, and expected years of dependency at age 65for males and females, for alternatives I, II, and

There are infinitely many principles of justice (conclusion). 24 “These, Socrates, said Parmenides, are a few, and only a few of the difficulties in which we are involved if

In this study it is aimed to investigate the total lipid and the fatty acid composition of pearl mullet which is the only fish species occurring in Lake Van and

It was decided that with the presence of such significant red flag signs that she should undergo advanced imaging, in this case an MRI, that revealed an underlying malignancy, which

information to reap an unfair benefit. Many of these donations were made at a time when it would have been illegal to make a sale of the same securities due to their access to this

To extend the program services to additional students and increase the sample for the research study, in 2014 Inwood House expanded the pool of schools further to include small,