Hadoop Distributed File System: Bhavneet Kaur B.Tech Computer Science 2 Year

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 34

Hadoop Distributed File System

-Bhavneet

Kaur
B.Tech Computer Science
2nd year

What is HDFS?
A file system that provides reliable data

storage and access across all the nodes in


a Hadoop cluster.
It links together the file systems on many
local nodes to create a single file system.
Very Large Distributed File System
10K nodes, 100 million files, 10PB

Basic Features:
Highly fault-tolerant:
Hardware failure is the norm rather than the

exception.
Hundreds or thousands of server machines, each
storing part of the file systems data.
Each component has a nontrivial probability of
failure means that some component of HDFS is
always non-functional.
Therefore, detection of faults and quick, automatic
recovery from them is a core architectural goal of
HDFS.
3

Streaming Data Access:


Applications that run on HDFS need

streaming access to their data sets.


HDFS is designed more for batch processing
rather than interactive use by users.
The emphasis is on high throughput of data
access rather than low latency of data access.

Large Data Sets :


Applications that run on HDFS have large

data sets.
A typical file in HDFS is gigabytes to
terabytes in size. Thus, HDFS is tuned to
support large files.
It should provide high aggregate data
bandwidth and scale to hundreds of nodes
in a single cluster.
It should support tens of millions of files in
a single instance.
5

Simple Coherency Model:


HDFS applications need a write-once-read-

many access model for files. A file once


created, written, and closed need not be
changed.
This assumption simplifies data coherency
issues and enables high throughput data
access.

Moving Computation is Cheaper than Moving Data


It is often better to migrate the computation

closer to where the data is located rather than


moving the data to where the application is
running.
HDFS provides interfaces for applications to
move themselves closer to where the data is
located.
This is especially true when the size of the data
set is huge.
This minimizes network congestion and
increases the overall throughput of the system.
7

Architecture

HDFS Architecture
Metadata ops

Metadata(Name, replicas..)
(/home/foo/data,6. ..

Namenode

Client
Block ops
Read

Datanodes

Datanodes
replication

B
Blocks

Rack1

Write
Client

Rack2

Namenode and Datanodes


Master/slave architecture

HDFS cluster consists of a single

Namenode, a master server that


manages the file system namespace
and regulates access to files by clients.
There are a number of DataNodes
usually one per node in a cluster.
The DataNodes manage storage
attached to the nodes that they run on.
10

HDFS exposes a file system namespace

and allows user data to be stored in files.


A file is split into one or more blocks and
set of blocks are stored in DataNodes.
DataNodes: serves read, write requests,
performs block creation, deletion, and
replication upon instruction from
Namenode.

11

File system Namespace


Hierarchical file system with directories

and files
Create, remove, move, rename etc.
Namenode maintains the file system
Any meta information changes to the file
system recorded by the Namenode.
An application can specify the number of
replicas of the file needed: replication
factor of the file. This information is
stored in the Namenode.
12

Data Replication
HDFS is designed to store very large files across

machines in a large cluster.


Each file is a sequence of blocks.
All blocks in the file except the last are of the same size.
Blocks are replicated for fault tolerance.
Block size and replicas are configurable per file.
Namenode periodically receives a Heartbeat and a
Blockreport from each of the DataNodes in the cluster.
Receipt of a Heartbeat implies that the DataNode is
functioning properly.
A Blockreport contains a list of all blocks on a
DataNode.

13

Replica Placement
The placement of the replicas is critical to

HDFS reliability and performance.


Optimizing replica placement distinguishes
HDFS from other distributed file systems.
Rack-aware replica placement:

Goal: improve reliability, availability and network

bandwidth utilization
Research topic
Many racks, communication between racks

are through switches.


Network bandwidth between machines on
the same rack is greater than those in
different racks.
14

Namenode determines the rack id for each

DataNode.
Replicas are typically placed on unique racks
Simple but non-optimal
Writes are expensive
Replication factor is 3
Another research topic?

Replicas are placed: one on a node in a local

rack, one on a different node in the local rack


and one on a node in a different rack.
1/3 of the replica on a node, 2/3 on a rack and
1/3 distributed evenly across remaining racks.
15

Replica Selection
Replica selection for READ operation:

HDFS tries to minimize the bandwidth


consumption and latency.
If there is a replica on the Reader node
then that is preferred.
HDFS cluster may span multiple data
centers: replica in the local data center
is preferred over the remote one.
16

Safemode Startup
On startup Namenode enters Safemode.
Replication of data blocks do not occur in Safemode.
Each DataNode checks in with Heartbeat and

BlockReport.
Namenode verifies that each block has acceptable
number of replicas
After a configurable percentage of safely replicated
blocks check in with the Namenode, Namenode exits
Safemode.
It then makes the list of blocks that need to be
replicated.
Namenode then proceeds to replicate these blocks to
other Datanodes.
17

Filesystem Metadata
The HDFS namespace is stored by Namenode.
Namenode uses a transaction log called the

EditLog to record every change that occurs to


the filesystem meta data.
For example, creating a new file.
Change replication factor of a file
EditLog is stored in the Namenodes local
filesystem
Entire filesystem namespace including mapping
of blocks to files and file system properties is
stored in a file FsImage. Stored in Namenodes
local filesystem.
18

Namenode
Keeps image of entire file system namespace

and file Blockmap in memory.


4GB of local RAM is sufficient to support the
above data structures that represent the huge
number of files and directories.
When the Namenode starts up it gets the
FsImage and Editlog from its local file system,
update FsImage with EditLog information and
then stores a copy of the FsImage on the
filesytstem as a checkpoint.
Periodic checkpointing is done. So that the
system can recover back to the last
checkpointed state in case of a crash.
19

Datanode
A Datanode stores data in files in its local file system.
Datanode has no knowledge about HDFS filesystem
It stores each block of HDFS data in a separate file.
Datanode does not create all files in the same

directory.
It uses heuristics to determine optimal number of files
per directory and creates directories appropriately:
Research issue?

When the filesystem starts up it generates a list of all

HDFS blocks and send this report to Namenode:


Blockreport.

20

Robustness

21

Objectives
Primary objective of HDFS is to store data

reliably in the presence of failures.


Three common failures are: Namenode
failure, Datanode failure and network
partition.

22

DataNode failure and


heartbeat

A network partition can cause a subset of

Datanodes to lose connectivity with the


Namenode.
Namenode detects this condition by the absence
of a Heartbeat message.
Namenode marks Datanodes without Hearbeat
and does not send any IO requests to them.
Any data registered to the failed Datanode is not
available to the HDFS.
Also the death of a Datanode may cause
replication factor of some of the blocks to fall
below their specified value.
23

Re-replication
The necessity for re-replication may arise

due to:
A Datanode may become unavailable,
A replica may become corrupted,
A hard disk on a Datanode may fail, or
The replication factor on the block may be

increased.

24

Cluster Rebalancing
HDFS architecture is compatible with data

rebalancing schemes.
A scheme might move data from one Datanode
to another if the free space on a Datanode falls
below a certain threshold.
In the event of a sudden high demand for a
particular file, a scheme might dynamically
create additional replicas and rebalance other
data in the cluster.
These types of data rebalancing are not yet
implemented: research issue.
25

Data Integrity
Consider a situation: a block of data fetched from

Datanode arrives corrupted.


This corruption may occur because of faults in a
storage device, network faults, or buggy software.
A HDFS client creates the checksum of every block
of its file and stores it in hidden files in the HDFS
namespace.
When a clients retrieves the contents of file, it
verifies that the corresponding checksums match.
If does not match, the client can retrieve the block
from a replica.

26

Metadata Disk Failure


FsImage and EditLog are central data structures of

HDFS.
A corruption of these files can cause a HDFS instance
to be non-functional.
For this reason, a Namenode can be configured to
maintain multiple copies of the FsImage and EditLog.
Multiple copies of the FsImage and EditLog files are
updated synchronously.
Meta-data is not data-intensive.
The Namenode could be single point failure:
automatic failover is NOT supported! Another
research topic.
27

Data Organization

28

06/29/15

Data Blocks
HDFS support write-once-read-many with

reads at streaming speeds.


A typical block size is 64MB (or even 128
MB).
A file is chopped into 64MB chunks and
stored.

29

Staging
A client request to create a file does not reach

Namenode immediately.
HDFS client caches the data into a temporary
file. When the data reached a HDFS block size
the client contacts the Namenode.
Namenode inserts the filename into its
hierarchy and allocates a data block for it.
The Namenode responds to the client with the
identity of the Datanode and the destination of
the replicas (Datanodes) for the block.
Then the client flushes it from its local memory.

30

Staging (contd.)
The client sends a message that the file is

closed.
Namenode proceeds to commit the file for
creation operation into the persistent store.
If the Namenode dies before file is closed,
the file is lost.
This client side caching is required to avoid
network congestion; also it has precedence
is AFS (Andrew file system).

31

Replication Pipelining
When the client receives response from

Namenode, it flushes its block in small


pieces (4K) to the first replica, that in turn
copies it to the next replica and so on.
Thus data is pipelined from Datanode to
the next.

32

Space Reclamation
When a file is deleted by a client, HDFS renames file

to a file in be the /trash directory for a configurable


amount of time.
A client can request for an undelete in this allowed
time.
After the specified time the file is deleted and the
space is reclaimed.
When the replication factor is reduced, the Namenode
selects excess replicas that can be deleted.
Next heartbeat(?) transfers this information to the
Datanode that clears the blocks for use.

33

34

06/29/15

You might also like