Hadoop File System
*
1
What’s HDFS
2
Introduction to HDFS
Components of HDFS
There are two (and a half) types of machines in a HDFS cluster
3
Introduction to HDFS
HDFS Architecture
4
Introduction to HDFS
Unique features of HDFS
HDFS also has a bunch of unique features that make it ideal for distributed systems:
HDFS is designed to process large data sets with write-once-read-many semantics, it is not for low latency access
5
Introduction to HDFS
HDFS – Data Organization
6
Introduction to HDFS
Read Operation in HDFS
7
Introduction to HDFS
Write Operation in HDFS
8
Introduction to HDFS
HDFS Security
9
Introduction to HDFS
HDFS Configuration
HDFS Defaults
HDFS conf file - /etc/hadoop/conf/hdfs-site.xml
<property>
<name>dfs.namenode.name.dir</name>
<value>file:///data1/cloudera/dfs/nn,file:///data2/cloudera/dfs/nn</value>
</property>
<property>
<name>dfs.blocksize</name>
<value>268435456</value>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<property>
<name>dfs.namenode.http-address</name>
<value>itracXXX.cern.ch:50070</value>
</property>
10
Introduction to HDFS
Interfaces to HDFS
However the command line is one of the simplest and most familiar
Introduction to HDFS
11
HDFS – Shell Commands
There are two types of shell commands
User Commands
hdfs dfs – runs filesystem commands on the HDFS
hdfs fsck – runs a HDFS filesystem checking command
Administration Commands
hdfs dfsadmin – runs HDFS administration commands
12
Introduction to HDFS
HDFS – User Commands (dfs)
List directory contents
Display the disk space used by files
13
Introduction to HDFS
hdfs dfs –ls
hdfs dfs -ls /
hdfs dfs -ls -R /var
hdfs dfs -du -h /
hdfs dfs -du /hbase/data/hbase/namespace/
hdfs dfs -du -h /hbase/data/hbase/namespace/
hdfs dfs -du -s /hbase/data/hbase/namespace/
HDFS – User Commands (dfs)
Copy data to HDFS
Copy the file back to local filesystem
Introduction to HDFS
14
hdfs dfs -mkdir tdata
hdfs dfs -ls
hdfs dfs -copyFromLocal tutorials/data/geneva.csv tdata
hdfs dfs -ls –R
cd tutorials/data/
hdfs dfs –copyToLocal tdata/geneva.csv geneva.csv.hdfs
md5sum geneva.csv geneva.csv.hdfs
HDFS – User Commands (acls)
List acl for a file
List the file statistics – (%r – replication factor)
Write to hdfs reading from stdin
Introduction to HDFS
15
hdfs dfs -getfacl tdata/geneva.csv
hdfs dfs -stat "%r" tdata/geneva.csv
echo "blah blah blah" | hdfs dfs -put - tdataset/tfile.txt
hdfs dfs -ls –R
hdfs dfs -cat tdataset/tfile.txt
HDFS – User Commands (fsck)
Removing a file
List the blocks of a file and their locations
Print missing blocks and the files they belong to
Introduction to HDFS
16
hdfs dfs -rm tdataset/tfile.txt
hdfs dfs -ls –R
hdfs fsck /user/cloudera/tdata/geneva.csv -files -blocks –locations
hdfs fsck / -list-corruptfileblocks
HDFS – Adminstration Commands
Comprehensive status report of HDFS cluster
Prints a tree of racks and their nodes
Get the information for a given datanode (like ping)
17
Introduction to HDFS
hdfs dfsadmin –report
hdfs dfsadmin –printTopology
hdfs dfsadmin -getDatanodeInfo localhost:50020
HDFS – Advanced Commands
Get a list of namenodes in the Hadoop cluster
Dump the NameNode fsimage to XML file
The general command line syntax is
hdfs command [genericOptions] [commandOptions]
18
Introduction to HDFS
hdfs getconf –namenodes
cd /var/lib/hadoop-hdfs/cache/hdfs/dfs/name/current
hdfs oiv -i fsimage_0000000000000003388 -o /tmp/fsimage.xml -p XML
Other Interfaces to HDFS
HTTP Interface
MountableHDFS – FUSE
Once mounted all operations on HDFS can be performed using standard Unix utilities such as 'ls', 'cd', 'cp', 'mkdir', 'find', 'grep',
Introduction to HDFS
19
http://quickstart.cloudera:50070
mkdir /home/cloudera/hdfs
sudo hadoop-fuse-dfs dfs://quickstart.cloudera:8020 /home/cloudera/hdfs
Basic Features: HDFS
*
20
Fault tolerance
*
21
Data Characteristics
*
22
MapReduce
Cat
Bat
Dog
Other
Words
(size:
TByte)
map
map
map
map
split
split
split
split
combine
combine
combine
reduce
reduce
reduce
part0
part1
part2
*
23
Architecture
*
24
Namenode and Datanodes
*
25
HDFS Architecture
*
26
Namenode
B
replication
Rack1
Rack2
Client
Blocks
Datanodes
Datanodes
Client
Write
Read
Metadata ops
Metadata(Name, replicas..)
(/home/foo/data,6. ..
Block ops
File system Namespace
*
27
Data Replication
*
28
Replica Placement
*
29
Replica Selection
*
30
Safemode Startup
*
31
Filesystem Metadata
*
32
Namenode
*
33
Datanode
*
34
Protocol
*
35
The Communication Protocol
*
36
Robustness
*
37
Objectives
*
38
DataNode failure and heartbeat
*
39
Re-replication
*
40
Cluster Rebalancing
*
41
Data Integrity
*
42
Metadata Disk Failure
*
43
Data Organization
*
44
Data Blocks
*
45
Staging
*
46
Staging (contd.)
*
47
Replication Pipelining
*
48
API (Accessibility)
*
49
Application Programming Interface
*
50
FS Shell, Admin and Browser Interface
/bin/hadoop dfs –mkdir /foodir
*
51
Space Reclamation
*
52
Summary
*
53