SlideShare a Scribd company logo
www.protechskills.com
Protechskills
HDFS
Hadoop Distributed File System
www.protechskills.com
Protechskills
Topics Covered
 Design Goals
 Hadoop Blocks
 Rack Awareness, Replica Placement & Selection
 Permissions Model
 Anatomy of a File Write / Read on HDFS
 FileSystem Image and Edit Logs
 HDFS Check Pointing Process
 Directory Structure - NameNode, Secondary NameNode , DataNode
 Safe Mode
www.protechskills.com
Protechskills
HDFS Design Goals
 Hardware Failure - Detection of faults and quick, automatic recovery
 Streaming Data Access - High throughput of data access (Batch Processing of data)
 Large Data Sets - Gigabytes to terabytes in size.
 Simple Coherency Model – Write once read many access model for files
 Moving computation is cheaper than moving data
www.protechskills.com
Protechskills
NameNode
Datanode_1 Datanode_2 Datanode_3
HDFS
Block 1
HDFS
Block 2
HDFS
Block 3 Block 4
Storage & Replication of Blocks in HDFS
Filedividedintoblocks
Block 1
Block 2
Block 3
Block 4
www.protechskills.com
Protechskills
Blocks
 Minimum amount of data that can be read or write - 64 MB by default
 Minimize the cost of seeks
 A file can be larger than any single disk in the network
 Simplifies the storage subsystem – Same size & eliminating metadata concerns
 Provides fault tolerance and availability
www.protechskills.com
Protechskills
Hadoop Rack Awareness
 Get maximum performance out of Hadoop
cluster
 To provide reliable storage when dealing with
DataNode failure issues.
 Resolution of the slave's DNS name (also IP
address) to a rack id.
 Interface provided in Hadoop
DNSToSwitchMapping, Default implementation
is ScriptBasedMapping
Rack Topology - /rack1 & /rack2
www.protechskills.com
Protechskills
HADOOP_CONF={${HADOOP_HOME}/conf
while [ $# -gt 0 ] ; do
nodeArg=$1
exec< ${HADOOP_CONF}/topology.data
result=""
while read line ; do
ar=( $line )
if [ "${ar[0]}" = "$nodeArg" ] ; then
result="${ar[1]}"
fi
done
shift
if [ -z "$result" ] ; then
echo -n "/default/rack "
else
echo -n "$result "
fi
done
Sample Script
192.168.56.101 /dc1/rack1
192.168.56.102 /dc1/rack2
192.168.56.103 /dc1/rack2
Sample Data (topology.data)
Rack Awareness Configuration
File : hdfs-site.xml
Property : topology.node.switch.mapping.impl
Default Value : ScriptBasedMapping class
Property : topology.script.file.name
Value : <Absolute path to script file>
Sample Command : ./topology.sh 192.168.56.101
Output : /dc1/rack1
Ref Hadoop Wiki
http://wiki.apache.org/hadoop/topology_rack_awareness_scripts
www.protechskills.com
Protechskills
Replica Placement
 Critical to HDFS reliability and
performance
 Improve data reliability,
availability, and network
bandwidth utilization
Distance b/w Hadoop
Client and DataNode
Same Node : d=0
Same Rack : d=2
Same Data Centre
different rack
: d=4
Different Data Centre : d=6
www.protechskills.com
Protechskills
Replica Placement cont..
Default Strategy :
a) First replica on the same node as the client.
b) Second replica is placed on a different rack from the first (off-rack) chosen at random
c) Third replica is placed on the same rack as the second, but on a different node chosen at random.
d) Further replicas are placed on random nodes on the cluster
Replica Selection - HDFS tries to satisfy a read request from a replica that is closest to the
reader.
www.protechskills.com
Protechskills
Permissions Model
 Directory or file flag, permissions, replication, owner, group, file size, modification date,
and full path.
 User Name : ‘whoami’
 Group List : ‘bash -c groups’
 Super-User & Web Server
www.protechskills.com
Protechskills
Anatomy of a File Write
 Client creates the file by calling create()
method
 NameNode validates & processes the
create request
 Spilt file into packets (DataQueue)
 DataStreamer asks NameNode for
block / node mapping & pipelines are
created among nodes.
www.protechskills.com
Protechskills
Anatomy of a File Write (cont..)
 DataStreamer streams the packets to
the first DataNode
 DataNode forwards the copied packet
to the next DataNode in the pipeline
 DFSOutputStream also maintains the
ack queue and removes the packets
after receiving acknowledgement from
the DataNodes
 Client calls close() on the stream
www.protechskills.com
Protechskills
Anatomy of a File Read
 Client calls open() on the FileSystem
object
 DistributedFileSystem calls the
NameNode to determine the locations of
the blocks
 NameNode validates request & for each
block returns the list of DataNodes.
 DistributedFileSystem returns an input
stream that supports file seeks to the
client
www.protechskills.com
Protechskills
Anatomy of a File Read (cont..)
 Client calls read() on the stream
 When the end of the block is reached,
DFSInputStream will close the connection
to the DataNode, then find the best
DataNode for the next block.
 Client calls close() on the stream
www.protechskills.com
Protechskills
FileSystem Image and Edit Logs
 fsimage file is a persistent checkpoint of the file-system metadata
 When a client performs a write operation, it is first recorded in the edit log.
 The NameNode also has an in-memory representation of the files-ystem
metadata, which it updates after the edit log has been modified
 Secondary NameNode is used to produce checkpoints of the primary’s in-
memory files-ystem metadata
www.protechskills.com
Protechskills
Check Pointing Process
 Secondary NameNode asks the primary to roll its edits file,
so new edits go to a new file.
 NameNode sends the fsimage and edits (using HTTP GET).
 Secondary NameNode loads fsimage into memory, applies
each operation from edits, then creates a new consolidated
fsimage file.
 Secondary NameNode sends the new fsimage back to the
primary (using HTTP POST).
 Primary replaces the old fsimage with the new one.
Updates the fstime file to record the time for checkpoint.
www.protechskills.com
Protechskills
Directory Structure
NameNode (On NameNode only)
${dfs.name.dir}/current/VERSION
/edits
/fsimage
/fstime
Secondary NameNode (On SecNameNode Only)
${fs.checkpoint.dir}/current/VERSION
/edits
/fsimage
/fstime
/previous.checkpoint/VERSION
/edits
/fsimage
/fstime
DataNode (On all DataNodes)
${dfs.data.dir}/current/VERSION
/blk_<id_1>
/blk_<id_1>.meta
/blk_<id_2>
/blk_<id_2>.meta
/...
/blk_<id_64>
/blk_<id_64>.meta
/subdir0/
/subdir1/
/...
Block Count for a directory
dfs.datanode.numblocks property
www.protechskills.com
Protechskills
Safe Mode
 On start-up, NameNode loads its image file (fsimage) into memory and applies the edits from the edit
log (edits).
 It does the check pointing process itself. without recourse to the Secondary NameNode.
 Namenode is running in safe mode (offers only a read-only view to clients)
 The locations of blocks in the system are not persisted by the NameNode - this information resides with
the DataNodes, in the form of a list of the blocks it is storing.
 Safe mode is needed to give the DataNodes time to check in to the NameNode with their block lists
 Safe mode is exited when the minimal replication condition is reached, plus an extension time of 30
seconds.
www.protechskills.com
Protechskills
Safe Mode Properties
Property Type Default Value Description
dfs.safemode.threshold.pct float 0.999
The proportion of blocks in the system that must meet the minimum
replication level defined by dfs.replication.min before the namenode will exit
safe mode. Setting this value to 0 or less forces the namenode not to start in
safe mode. Setting this value to more than 1 means the namenode never exits
safe mode.
dfs.safemode.extension int 30, 000
The time, in milliseconds, to extend safe mode by after the minimum
replication condition defined by dfs.safemode.threshold.pct has been
satisfied. For small clusters (tens of nodes), it can be set to 0.
Syntax : hadoop dfsadmin –safemode [Options]
Options : get / wait / enter / leave
Safe Mode
Commands Options
www.protechskills.com
Protechskills
References
 Hadoop Apache Website – http://hadoop.apache.org/
 Hadoop The Definitive Guide 3rd Edition By Oreilly
www.protechskills.com
Protechskills

More Related Content

PPTX
Hadoop File system (HDFS)
PPTX
Data Marts.pptx
PPT
Coda file system
PPT
Association rule mining
PPTX
Column oriented database
PPT
Hive(ppt)
PDF
PDF
Data warehouse architecture
Hadoop File system (HDFS)
Data Marts.pptx
Coda file system
Association rule mining
Column oriented database
Hive(ppt)
Data warehouse architecture

What's hot (20)

PPTX
Dm from databases perspective u 1
PDF
IaaS, SaaS, PasS : Cloud Computing
PPTX
Distributed database
PPTX
Hadoop HDFS Concepts
PPT
similarity measure
PPTX
Dynamic Itemset Counting
PPTX
multi dimensional data model
PPT
Object Oriented Database Management System
PPTX
Semantic Networks
PPTX
Apriori algorithm
PPT
01 Data Mining: Concepts and Techniques, 2nd ed.
PPTX
Transactions and Concurrency Control
PPTX
Distributed concurrency control
PDF
DDS for Internet of Things (IoT)
PPTX
OLAP v/s OLTP
PPTX
Adbms 11 object structure and type constructor
PPTX
Adbms 17 object query language
PPTX
Distributed DBMS - Unit 3 - Distributed DBMS Architecture
PPTX
Query optimization
Dm from databases perspective u 1
IaaS, SaaS, PasS : Cloud Computing
Distributed database
Hadoop HDFS Concepts
similarity measure
Dynamic Itemset Counting
multi dimensional data model
Object Oriented Database Management System
Semantic Networks
Apriori algorithm
01 Data Mining: Concepts and Techniques, 2nd ed.
Transactions and Concurrency Control
Distributed concurrency control
DDS for Internet of Things (IoT)
OLAP v/s OLTP
Adbms 11 object structure and type constructor
Adbms 17 object query language
Distributed DBMS - Unit 3 - Distributed DBMS Architecture
Query optimization
Ad

Similar to Hadoop HDFS Concepts (20)

PPTX
Introduction to hadoop and hdfs
PPTX
Introduction to HDFS and MapReduce
PPTX
PPTX
Hadoop Interview Questions And Answers Part-1 | Big Data Interview Questions ...
PDF
Big data interview questions and answers
PPTX
Hadoop BRamamurthy ajjaahdvddvdnsmsjdjfj
ODP
Hadoop admin
PDF
Hadoop operations basic
PDF
HDFS Design Principles
PDF
Apache Hadoop In Theory And Practice
PDF
Hdfs Dhruba
PDF
HDFS Architecture
PPT
Hadoop training in hyderabad-kellytechnologies
PPTX
PPTX
Hadoop at a glance
PPTX
Hadoop HDFS Architeture and Design
PDF
Document 22.pdf
PPT
Hadoop training in bangalore-kellytechnologies
PDF
Hdfs java api
PPT
Hadoop-professional-software-development-course-in-mumbai
Introduction to hadoop and hdfs
Introduction to HDFS and MapReduce
Hadoop Interview Questions And Answers Part-1 | Big Data Interview Questions ...
Big data interview questions and answers
Hadoop BRamamurthy ajjaahdvddvdnsmsjdjfj
Hadoop admin
Hadoop operations basic
HDFS Design Principles
Apache Hadoop In Theory And Practice
Hdfs Dhruba
HDFS Architecture
Hadoop training in hyderabad-kellytechnologies
Hadoop at a glance
Hadoop HDFS Architeture and Design
Document 22.pdf
Hadoop training in bangalore-kellytechnologies
Hdfs java api
Hadoop-professional-software-development-course-in-mumbai
Ad

Recently uploaded (20)

PDF
Pre independence Education in Inndia.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Business Ethics Teaching Materials for college
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Pharma ospi slides which help in ospi learning
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Pre independence Education in Inndia.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Business Ethics Teaching Materials for college
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Microbial diseases, their pathogenesis and prophylaxis
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Classroom Observation Tools for Teachers
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPH.pptx obstetrics and gynecology in nursing
Pharma ospi slides which help in ospi learning
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...

Hadoop HDFS Concepts

  • 2. www.protechskills.com Protechskills Topics Covered  Design Goals  Hadoop Blocks  Rack Awareness, Replica Placement & Selection  Permissions Model  Anatomy of a File Write / Read on HDFS  FileSystem Image and Edit Logs  HDFS Check Pointing Process  Directory Structure - NameNode, Secondary NameNode , DataNode  Safe Mode
  • 3. www.protechskills.com Protechskills HDFS Design Goals  Hardware Failure - Detection of faults and quick, automatic recovery  Streaming Data Access - High throughput of data access (Batch Processing of data)  Large Data Sets - Gigabytes to terabytes in size.  Simple Coherency Model – Write once read many access model for files  Moving computation is cheaper than moving data
  • 4. www.protechskills.com Protechskills NameNode Datanode_1 Datanode_2 Datanode_3 HDFS Block 1 HDFS Block 2 HDFS Block 3 Block 4 Storage & Replication of Blocks in HDFS Filedividedintoblocks Block 1 Block 2 Block 3 Block 4
  • 5. www.protechskills.com Protechskills Blocks  Minimum amount of data that can be read or write - 64 MB by default  Minimize the cost of seeks  A file can be larger than any single disk in the network  Simplifies the storage subsystem – Same size & eliminating metadata concerns  Provides fault tolerance and availability
  • 6. www.protechskills.com Protechskills Hadoop Rack Awareness  Get maximum performance out of Hadoop cluster  To provide reliable storage when dealing with DataNode failure issues.  Resolution of the slave's DNS name (also IP address) to a rack id.  Interface provided in Hadoop DNSToSwitchMapping, Default implementation is ScriptBasedMapping Rack Topology - /rack1 & /rack2
  • 7. www.protechskills.com Protechskills HADOOP_CONF={${HADOOP_HOME}/conf while [ $# -gt 0 ] ; do nodeArg=$1 exec< ${HADOOP_CONF}/topology.data result="" while read line ; do ar=( $line ) if [ "${ar[0]}" = "$nodeArg" ] ; then result="${ar[1]}" fi done shift if [ -z "$result" ] ; then echo -n "/default/rack " else echo -n "$result " fi done Sample Script 192.168.56.101 /dc1/rack1 192.168.56.102 /dc1/rack2 192.168.56.103 /dc1/rack2 Sample Data (topology.data) Rack Awareness Configuration File : hdfs-site.xml Property : topology.node.switch.mapping.impl Default Value : ScriptBasedMapping class Property : topology.script.file.name Value : <Absolute path to script file> Sample Command : ./topology.sh 192.168.56.101 Output : /dc1/rack1 Ref Hadoop Wiki http://wiki.apache.org/hadoop/topology_rack_awareness_scripts
  • 8. www.protechskills.com Protechskills Replica Placement  Critical to HDFS reliability and performance  Improve data reliability, availability, and network bandwidth utilization Distance b/w Hadoop Client and DataNode Same Node : d=0 Same Rack : d=2 Same Data Centre different rack : d=4 Different Data Centre : d=6
  • 9. www.protechskills.com Protechskills Replica Placement cont.. Default Strategy : a) First replica on the same node as the client. b) Second replica is placed on a different rack from the first (off-rack) chosen at random c) Third replica is placed on the same rack as the second, but on a different node chosen at random. d) Further replicas are placed on random nodes on the cluster Replica Selection - HDFS tries to satisfy a read request from a replica that is closest to the reader.
  • 10. www.protechskills.com Protechskills Permissions Model  Directory or file flag, permissions, replication, owner, group, file size, modification date, and full path.  User Name : ‘whoami’  Group List : ‘bash -c groups’  Super-User & Web Server
  • 11. www.protechskills.com Protechskills Anatomy of a File Write  Client creates the file by calling create() method  NameNode validates & processes the create request  Spilt file into packets (DataQueue)  DataStreamer asks NameNode for block / node mapping & pipelines are created among nodes.
  • 12. www.protechskills.com Protechskills Anatomy of a File Write (cont..)  DataStreamer streams the packets to the first DataNode  DataNode forwards the copied packet to the next DataNode in the pipeline  DFSOutputStream also maintains the ack queue and removes the packets after receiving acknowledgement from the DataNodes  Client calls close() on the stream
  • 13. www.protechskills.com Protechskills Anatomy of a File Read  Client calls open() on the FileSystem object  DistributedFileSystem calls the NameNode to determine the locations of the blocks  NameNode validates request & for each block returns the list of DataNodes.  DistributedFileSystem returns an input stream that supports file seeks to the client
  • 14. www.protechskills.com Protechskills Anatomy of a File Read (cont..)  Client calls read() on the stream  When the end of the block is reached, DFSInputStream will close the connection to the DataNode, then find the best DataNode for the next block.  Client calls close() on the stream
  • 15. www.protechskills.com Protechskills FileSystem Image and Edit Logs  fsimage file is a persistent checkpoint of the file-system metadata  When a client performs a write operation, it is first recorded in the edit log.  The NameNode also has an in-memory representation of the files-ystem metadata, which it updates after the edit log has been modified  Secondary NameNode is used to produce checkpoints of the primary’s in- memory files-ystem metadata
  • 16. www.protechskills.com Protechskills Check Pointing Process  Secondary NameNode asks the primary to roll its edits file, so new edits go to a new file.  NameNode sends the fsimage and edits (using HTTP GET).  Secondary NameNode loads fsimage into memory, applies each operation from edits, then creates a new consolidated fsimage file.  Secondary NameNode sends the new fsimage back to the primary (using HTTP POST).  Primary replaces the old fsimage with the new one. Updates the fstime file to record the time for checkpoint.
  • 17. www.protechskills.com Protechskills Directory Structure NameNode (On NameNode only) ${dfs.name.dir}/current/VERSION /edits /fsimage /fstime Secondary NameNode (On SecNameNode Only) ${fs.checkpoint.dir}/current/VERSION /edits /fsimage /fstime /previous.checkpoint/VERSION /edits /fsimage /fstime DataNode (On all DataNodes) ${dfs.data.dir}/current/VERSION /blk_<id_1> /blk_<id_1>.meta /blk_<id_2> /blk_<id_2>.meta /... /blk_<id_64> /blk_<id_64>.meta /subdir0/ /subdir1/ /... Block Count for a directory dfs.datanode.numblocks property
  • 18. www.protechskills.com Protechskills Safe Mode  On start-up, NameNode loads its image file (fsimage) into memory and applies the edits from the edit log (edits).  It does the check pointing process itself. without recourse to the Secondary NameNode.  Namenode is running in safe mode (offers only a read-only view to clients)  The locations of blocks in the system are not persisted by the NameNode - this information resides with the DataNodes, in the form of a list of the blocks it is storing.  Safe mode is needed to give the DataNodes time to check in to the NameNode with their block lists  Safe mode is exited when the minimal replication condition is reached, plus an extension time of 30 seconds.
  • 19. www.protechskills.com Protechskills Safe Mode Properties Property Type Default Value Description dfs.safemode.threshold.pct float 0.999 The proportion of blocks in the system that must meet the minimum replication level defined by dfs.replication.min before the namenode will exit safe mode. Setting this value to 0 or less forces the namenode not to start in safe mode. Setting this value to more than 1 means the namenode never exits safe mode. dfs.safemode.extension int 30, 000 The time, in milliseconds, to extend safe mode by after the minimum replication condition defined by dfs.safemode.threshold.pct has been satisfied. For small clusters (tens of nodes), it can be set to 0. Syntax : hadoop dfsadmin –safemode [Options] Options : get / wait / enter / leave Safe Mode Commands Options
  • 20. www.protechskills.com Protechskills References  Hadoop Apache Website – http://hadoop.apache.org/  Hadoop The Definitive Guide 3rd Edition By Oreilly