|
翻译:fly_hyp 欢迎访问我的博客:http://fly-hyp.iyunv.com/
翻译的有点业余,现在大约翻译了70%,今天是没有时间了,以后会再接再厉。
The Hadoop Distributed File System: Architecture and Design
Hadoop 分布式文件系统: 构架和设计
- Introduction
介绍
- Assumptions and Goals
假设和目标
- Hardware Failure
硬件失效
- Streaming Data Access
流模式数据访问
- Large Data Sets
大数据集支持
- Simple Coherency Model
- “Moving Computation is Cheaper than Moving Data”
- “移动计算方法比移动数据廉价”
- Portability Across Heterogeneous Hardware and Software Platforms
- 硬件和软件平台的可移植性
- Namenode and Datanodes
- 名字节点和数据节点
- The File System Namespace
- 文件系统名字空间
- Data Replication 数据副本
- Replica Placement: The First Baby Steps
- 副本的存放: 婴儿的第一步
- Replica Selection
- 副本的选择
- SafeMode
- 安全模式
- The Persistence of File System Metadata
- 文件系统元数据的持久化
- The Communication Protocols
- 通讯协议
- Robustness
健壮性
- Data Disk Failure, Heartbeats and Re-Replication
- 磁盘故障、心跳、再复制
- Cluster Rebalancing
- 群集的负载均衡
- Data Integrity
- 数据整合
- Metadata Disk Failure
- 元数据磁盘故障
- Snapshots
- 快照
- Data Organization
数据管理
- Data Blocks
数据块
- Staging
- 分段运输
- Replication Pipelining
- 管道式的复制
- Accessibility
访问方式
- DFSShell
- 命令行接口
- DFSAdmin
- 管理工具
- Browser Interface
- 浏览器借口
- Space Reclamation
空间的回收
- File Deletes and Undeletes
- 文件的删除和恢复
- Decrease Replication Factor
- 减少副本参数设置
- References
- 参考
Introduction
介绍
The Hadoop Distributed File System (HDFS)is a distributed file system designed to run on commodity hardware. Ithas many similarities with existing distributed file systems. However,the differences from other distributed file systems are significant.HDFS is highly fault-tolerant and is designed to be deployed onlow-cost hardware. HDFS provides high throughput access to applicationdata and is suitable for applications that have large data sets. HDFSrelaxes a few POSIX requirements to enable streaming access to filesystem data. HDFS was originally built as infrastructure for the ApacheNutch web search engine project. HDFS is part of the Apache Hadoop Coreproject. The project URL is http://hadoop.apache.org/core/.
Hadoop分布式文件系统(HDFS)是一种设计运行在一般硬件条件(非服务器)下的分布式文件系统. 他和现有的其他分布式文件系统有很多相似.但,和其他分布式文件系统的不同之处才是最重要的. HDFS 设计为运行在低成本的硬件上,且提供高可靠性的服务器.HDFS设计满足大数据量,大吞吐量的情况。HDFS提供POSIX标准的按流方式访问数据的方法。HDFS原先是Apache Nutch网站搜索引擎项目的一个基础部分. HDFS 是Hadoop Corex项目的一部分. 项目网址:http://hadoop.apache.org/core/.
Assumptions and Goals
假定和目标
Hardware Failure
硬件失效
Hardware failure is the norm rather than the exception. An HDFSinstance may consist of hundreds or thousands of server machines, eachstoring part of the file system’s data. The fact that there are a hugenumber of components and that each component has a non-trivialprobability of failure means that some component of HDFS is alwaysnon-functional. Therefore, detection of faults and quick, automaticrecovery from them is a core architectural goal of HDFS.
硬件失效比一般一场更为普遍. 一个HDFS运行实例可有包含几百或几千台服务器, 每一个存储一部分文件系统的数据.因为由大量的服务器组成,任何一个服务器的小概率的失效意味着整个文件系统的不能工作。因此检测错误,并且快速自动的恢复是HDFS的一个核心构架目标.
Streaming Data Access
流方式的数据访问
Applications that run on HDFS need streaming access to their datasets. They are not general purpose applications that typically run ongeneral purpose file systems. HDFS is designed more for batchprocessing rather than interactive use by users. The emphasis is onhigh throughput of data access rather than low latency of data access.POSIX imposes many hard requirements that are not needed forapplications that are targeted for HDFS. POSIX semantics in a few keyareas has been traded to increase data throughput rates.
应用程序需要通过流方式访问数据,他们不是运行在一般文件系统上的应用. HDFS设计为批处理模式,而不是交互模式. 强调高吞吐量而不是低延时。POSIX的一些语义,被认为是提高吞吐量的方式,对运行在HDFS上的应用是不需要。
Large Data Sets
大的数据集支持
Applications that run on HDFS have large data sets. A typical filein HDFS is gigabytes to terabytes in size. Thus, HDFS is tuned tosupport large files. It should provide high aggregate data bandwidthand scale to hundreds of nodes in a single cluster. It should supporttens of millions of files in a single instance.
运行在HDFS上的应用程序有很大的数据量. 典型的文件大小是G bytes 到 T bytes. 因此,HDFS需要调整到支持很大的文件,需要支持很大的数据带宽,以及在一个服务器群集中可扩展到几百个节点,支持数千万个文件。
Simple Coherency Model
简单的一致性模型
HDFS applications need a write-once-read-many access model forfiles. A file once created, written, and closed need not be changed.This assumption simplifies data coherency issues and enables highthroughput data access. A MapReduce application or a web crawlerapplication fits perfectly with this model. There is a plan to supportappending-writes to files in the future.
HDFS应用程序写一次读多次的文件访问模型. 文件一点别建立、写入、关闭,将不能被改变了.这个假定简化了文件一致性的术语,能够提高数据访问的吞吐量. 一个MapReduce应用程序或网络爬虫应用程序非常的适合这种模型.我们有个一个计划,在未来添加支持追加写入的功能.
“Moving Computation is Cheaper than Moving Data”
“移动计算方法比移动数据便宜”
A computation requested by an application is much more efficient ifit is executed near the data it operates on. This is especially truewhen the size of the data set is huge. This minimizes networkcongestion and increases the overall throughput of the system. Theassumption is that it is often better to migrate the computation closerto where the data is located rather than moving the data to where theapplication is running. HDFS provides interfaces for applications tomove themselves closer to where the data is located.
应用的一个计算请求假如在离数据更近的地方计算将会更有效率. 这样在数据十分巨大的时候更加明显.这样可以最小化网络阻塞和增加整个系统的吞吐量. 有个设想是,经常移动程序到他计算的数据附近,而不是经常移动数据到他相关的应用程序附近.HDFS为应用提供一个接口,方面他们(程序)移动自己到离他们数据更近的地方.
Portability Across Heterogeneous Hardware and Software Platforms
跨不同硬件和软件平台的和移植性
HDFS has been designed to be easily portable from one platform toanother. This facilitates widespread adoption of HDFS as a platform ofchoice for a large set of applications.
HDFS被设计为可以方便的从一个平台移植到另外一个平台. 这样有助于HDFS被大量的应用采纳.
Namenode and Datanodes
名字节点和数据节点
HDFS has a master/slave architecture. An HDFS cluster consists of a single Namenode,a master server that manages the file system namespace and regulatesaccess to files by clients. In addition, there are a number of Datanodes,usually one per node in the cluster, which manage storage attached tothe nodes that they run on. HDFS exposes a file system namespace andallows user data to be stored in files. Internally, a file is splitinto one or more blocks and these blocks are stored in a set ofDatanodes. The Namenode executes file system namespace operations likeopening, closing, and renaming files and directories. It alsodetermines the mapping of blocks to Datanodes. The Datanodes areresponsible for serving read and write requests from the file system’sclients. The Datanodes also perform block creation, deletion, andreplication upon instruction from the Namenode.
HDFS是一个主从构架. 一个HDFS群集有单个名字节点组成, 一个主服务器管理文件系统的名字空间和调节客户端对文件的访问. 另外, 存在一些数据节点,一般来说每一个在群集中的节点管理它运行所在机器的存储(磁盘). HDFS 暴露一个文件系统命名空间以及允许用户数据被存在文件中. 在内部,一个文件被分为一个或多个快,这些块被存在一系列的数据节点上.名字节点管理文件系统的操作,例如,打开文件、关闭文件、文件改名、目录维护。它也决定数据块到数据节点的映射.数据节点的责任是满足客户程序的读写请求。数据节点执行来自于名字节点的建立、删除、复制指令.

The Namenode and Datanode are pieces of software designed to run oncommodity machines. These machines typically run a GNU/Linux operatingsystem (OS).HDFS is built using the Java language; any machine that supports Javacan run the Namenode or the Datanode software. Usage of the highlyportable Java language means that HDFS can be deployed on a wide rangeof machines. A typical deployment has a dedicated machine that runsonly the Namenode software. Each of the other machines in the clusterruns one instance of the Datanode software. The architecture does notpreclude running multiple Datanodes on the same machine but in a realdeployment that is rarely the case.
The Namenode and Datanode are pieces of software designed to run oncommodity machines. These machines typically run a GNU/Linux operatingsystem (OS).HDFS is built using the Java language; any machine that supports Javacan run the Namenode or the Datanode software. Usage of the highlyportable Java language means that HDFS can be deployed on a wide rangeof machines. A typical deployment has a dedicated machine that runsonly the Namenode software. Each of the other machines in the clusterruns one instance of the Datanode software. The architecture does notpreclude running multiple Datanodes on the same machine but in a realdeployment that is rarely the case.
The existence of a single Namenode in a cluster greatly simplifiesthe architecture of the system. The Namenode is the arbitrator andrepository for all HDFS metadata. The system is designed in such a waythat user datanever flows through the Namenode.
The existence of a single Namenode in a cluster greatly simplifiesthe architecture of the system. The Namenode is the arbitrator andrepository for all HDFS metadata. The system is designed in such a waythat user datanever flows through the Namenode.
The File System Namespace
文件系统名字空间
HDFS supports a traditional hierarchical file organization. A useror an application can create directories and store files inside thesedirectories. The file system namespace hierarchy is similar to mostother existing file systems; one can create and remove files, move afile from one directory to another, or rename a file. HDFS does not yetimplement user quotas or access permissions. HDFS does not support hardlinks or soft links. However, the HDFS architecture does not precludeimplementing these features.
HDFS supports a traditional hierarchical file organization. A useror an application can create directories and store files inside thesedirectories. The file system namespace hierarchy is similar to mostother existing file systems; one can create and remove files, move afile from one directory to another, or rename a file. HDFS does not yetimplement user quotas or access permissions. HDFS does not support hardlinks or soft links. However, the HDFS architecture does not precludeimplementing these features.
The Namenode maintains the file system namespace. Any change to thefile system namespace or its properties is recorded by the Namenode. Anapplication can specify the number of replicas of a file that should bemaintained by HDFS. The number of copies of a file is called thereplication factor of that file. This information is stored by theNamenode.
The Namenode maintains the file system namespace. Any change to thefile system namespace or its properties is recorded by the Namenode. Anapplication can specify the number of replicas of a file that should bemaintained by HDFS. The number of copies of a file is called thereplication factor of that file. This information is stored by theNamenode.
Data Replication
数据复制
HDFS is designed to reliably store very large files across machinesin a large cluster. It stores each file as a sequence of blocks; allblocks in a file except the last block are the same size. The blocks ofa file are replicated for fault tolerance. The block size andreplication factor are configurable per file. An application canspecify the number of replicas of a file. The replication factor can bespecified at file creation time and can be changed later. Files in HDFSare write-once and have strictly one writer at any time.
The Namenode makes all decisions regarding replication of blocks. It periodically receives a Heartbeatand a Blockreportfrom each of the Datanodes in the cluster. Receipt of a Heartbeatimplies that the Datanode is functioning properly. A Blockreportcontains a list of all blocks on a Datanode.
Replica Placement: The First Baby Steps
数据副本的存放: 婴儿的第一步
The placement of replicas is critical to HDFS reliability andperformance. Optimizing replica placement distinguishes HDFS from mostother distributed file systems. This is a feature that needs lots oftuning and experience. The purpose of a rack-aware replica placementpolicy is to improve data reliability, availability, and networkbandwidth utilization. The current implementation for the replicaplacement policy is a first effort in this direction. The short-termgoals of implementing this policy are to validate it on productionsystems, learn more about its behavior, and build a foundation to testand research more sophisticated policies.
The placement of replicas is critical to HDFS reliability andperformance. Optimizing replica placement distinguishes HDFS from mostother distributed file systems. This is a feature that needs lots oftuning and experience. The purpose of a rack-aware replica placementpolicy is to improve data reliability, availability, and networkbandwidth utilization. The current implementation for the replicaplacement policy is a first effort in this direction. The short-termgoals of implementing this policy are to validate it on productionsystems, learn more about its behavior, and build a foundation to testand research more sophisticated policies.
Large HDFS instances run on a cluster of computers that commonlyspread across many racks. Communication between two nodes in differentracks has to go through switches. In most cases, network bandwidthbetween machines in the same rack is greater than network bandwidthbetween machines in different racks.
Large HDFS instances run on a cluster of computers that commonlyspread across many racks. Communication between two nodes in differentracks has to go through switches. In most cases, network bandwidthbetween machines in the same rack is greater than network bandwidthbetween machines in different racks.
The NameNode determines the rack id each DataNode belongs to via the process outlined in Rack Awareness.A simple but non-optimal policy is to place replicas on unique racks.This prevents losing data when an entire rack fails and allows use ofbandwidth from multiple racks when reading data. This policy evenlydistributes replicas in the cluster which makes it easy to balance loadon component failure. However, this policy increases the cost of writesbecause a write needs to transfer blocks to multiple racks.
The NameNode determines the rack id each DataNode belongs to via the process outlined in Rack Awareness.A simple but non-optimal policy is to place replicas on unique racks.This prevents losing data when an entire rack fails and allows use ofbandwidth from multiple racks when reading data. This policy evenlydistributes replicas in the cluster which makes it easy to balance loadon component failure. However, this policy increases the cost of writesbecause a write needs to transfer blocks to multiple racks.
For the common case, when the replication factor is three, HDFS’splacement policy is to put one replica on one node in the local rack,another on a different node in the local rack, and the last on adifferent node in a different rack. This policy cuts the inter-rackwrite traffic which generally improves write performance. The chance ofrack failure is far less than that of node failure; this policy doesnot impact data reliability and availability guarantees. However, itdoes reduce the aggregate network bandwidth used when reading datasince a block is placed in only two unique racks rather than three.With this policy, the replicas of a file do not evenly distributeacross the racks. One third of replicas are on one node, two thirds ofreplicas are on one rack, and the other third are evenly distributedacross the remaining racks. This policy improves write performancewithout compromising data reliability or read performance.
For the common case, when the replication factor is three, HDFS’splacement policy is to put one replica on one node in the local rack,another on a different node in the local rack, and the last on adifferent node in a different rack. This policy cuts the inter-rackwrite traffic which generally improves write performance. The chance ofrack failure is far less than that of node failure; this policy doesnot impact data reliability and availability guarantees. However, itdoes reduce the aggregate network bandwidth used when reading datasince a block is placed in only two unique racks rather than three.With this policy, the replicas of a file do not evenly distributeacross the racks. One third of replicas are on one node, two thirds ofreplicas are on one rack, and the other third are evenly distributedacross the remaining racks. This policy improves write performancewithout compromising data reliability or read performance.
The current, default replica placement policy described here is a work in progress.
The current, default replica placement policy described here is a work in progress.
Replica Selection
复制选择
To minimize global bandwidth consumption and read latency, HDFStries to satisfy a read request from a replica that is closest to thereader. If there exists a replica on the same rack as the reader node,then that replica is preferred to satisfy the read request. If angg/HDFS cluster spans multiple data centers, then a replica that isresident in the local data center is preferred over any remote replica.
为了减少全局带宽和读延时, HDFS尝试把最近的一个副本给读的应用. 假如和读的应用在同一个机架存在副本, 则这个副本优先被读取. 假如HDFS群集存在多个数据中心, 则本地数据中心优先被读取.
SafeMode
安全模式
On startup, the Namenode enters a special state called Safemode.Replication of data blocks does not occur when the Namenode is in theSafemode state. The Namenode receives Heartbeat and Blockreportmessages from the Datanodes. A Blockreport contains the list of datablocks that a Datanode is hosting. Each block has a specified minimumnumber of replicas. A block is considered safely replicatedwhen the minimum number of replicas of that data block has checked inwith the Namenode. After a configurable percentage of safely replicateddata blocks checks in with the Namenode (plus an additional 30seconds), the Namenode exits the Safemode state. It then determines thelist of data blocks (if any) that still have fewer than the specifiednumber of replicas. The Namenode then replicates these blocks to otherDatanodes.
On startup, the Namenode enters a special state called Safemode.Replication of data blocks does not occur when the Namenode is in theSafemode state. The Namenode receives Heartbeat and Blockreportmessages from the Datanodes. A Blockreport contains the list of datablocks that a Datanode is hosting. Each block has a specified minimumnumber of replicas. A block is considered safely replicatedwhen the minimum number of replicas of that data block has checked inwith the Namenode. After a configurable percentage of safely replicateddata blocks checks in with the Namenode (plus an additional 30seconds), the Namenode exits the Safemode state. It then determines thelist of data blocks (if any) that still have fewer than the specifiednumber of replicas. The Namenode then replicates these blocks to otherDatanodes.
The Persistence of File System Metadata
The Persistence of File System Metadata
The HDFS namespace is stored by the Namenode. The Namenode uses a transaction log called the EditLogto persistently record every change that occurs to file system metadata.For example, creating a new file in HDFS causes the Namenode to inserta record into the EditLog indicating this. Similarly, changing thereplication factor of a file causes a new record to be inserted intothe EditLog. The Namenode uses a file in its localhost OSfile system to store the EditLog. The entire file system namespace,including the mapping of blocks to files and file system properties, isstored in a file called the FsImage. The FsImage is stored as a file in the Namenode’s local file system too.
The HDFS namespace is stored by the Namenode. The Namenode uses a transaction log called the EditLogto persistently record every change that occurs to file system metadata.For example, creating a new file in HDFS causes the Namenode to inserta record into the EditLog indicating this. Similarly, changing thereplication factor of a file causes a new record to be inserted intothe EditLog. The Namenode uses a file in its localhost OSfile system to store the EditLog. The entire file system namespace,including the mapping of blocks to files and file system properties, isstored in a file called the FsImage. The FsImage is stored as a file in the Namenode’s local file system too.
The Namenode keeps an image of the entire file system namespace and file Blockmapin memory. This key metadata item is designed to be compact, such thata Namenode with 4 GB of RAM is plenty to support a huge number of filesand directories. When the Namenode starts up, it reads the FsImage andEditLog from disk, applies all the transactions from the EditLog to thein-memory representation of the FsImage, and flushes out this newversion into a new FsImage on disk. It can then truncate the oldEditLog because its transactions have been applied to the persistentFsImage. This process is called a checkpoint. In the currentimplementation, a checkpoint only occurs when the Namenode starts up.Work is in progress to support periodic checkpointing in the nearfuture.
The Namenode keeps an image of the entire file system namespace and file Blockmapin memory. This key metadata item is designed to be compact, such thata Namenode with 4 GB of RAM is plenty to support a huge number of filesand directories. When the Namenode starts up, it reads the FsImage andEditLog from disk, applies all the transactions from the EditLog to thein-memory representation of the FsImage, and flushes out this newversion into a new FsImage on disk. It can then truncate the oldEditLog because its transactions have been applied to the persistentFsImage. This process is called a checkpoint. In the currentimplementation, a checkpoint only occurs when the Namenode starts up.Work is in progress to support periodic checkpointing in the nearfuture.
The Datanode stores HDFS data in files in its local file system. TheDatanode has no knowledge about HDFS files. It stores each block ofHDFS data in a separate file in its local file system. The Datanodedoes not create all files in the same directory. Instead, it uses aheuristic to determine the optimal number of files per directory andcreates subdirectories appropriately. It is not optimal to create alllocal files in the same directory because the local file system mightnot be able to efficiently support a huge number of files in a singledirectory. When a Datanode starts up, it scans through its local filesystem, generates a list of all HDFS data blocks that correspond toeach of these local files and sends this report to the Namenode: thisis the Blockreport.
The Datanode stores HDFS data in files in its local file system. TheDatanode has no knowledge about HDFS files. It stores each block ofHDFS data in a separate file in its local file system. The Datanodedoes not create all files in the same directory. Instead, it uses aheuristic to determine the optimal number of files per directory andcreates subdirectories appropriately. It is not optimal to create alllocal files in the same directory because the local file system mightnot be able to efficiently support a huge number of files in a singledirectory. When a Datanode starts up, it scans through its local filesystem, generates a list of all HDFS data blocks that correspond toeach of these local files and sends this report to the Namenode: thisis the Blockreport.
The Communication Protocols
通讯协议
All HDFS communication protocols are layered on top of the TCP/IPprotocol. A client establishes a connection to a configurable TCPport on the Namenode machine. It talks the ClientProtocolwith the Namenode. The Datanodes talk to the Namenode using the DatanodeProtocol. A Remote Procedure Call (RPC)abstraction wraps both the ClientProtocol and the DatanodeProtocol. Bydesign, the Namenode never initiates any RPCs. Instead, it onlyresponds to RPC requests issued by Datanodes or clients.
All HDFS communication protocols are layered on top of the TCP/IPprotocol. A client establishes a connection to a configurable TCPport on the Namenode machine. It talks the ClientProtocolwith the Namenode. The Datanodes talk to the Namenode using the DatanodeProtocol. A Remote Procedure Call (RPC)abstraction wraps both the ClientProtocol and the DatanodeProtocol. Bydesign, the Namenode never initiates any RPCs. Instead, it onlyresponds to RPC requests issued by Datanodes or clients.
Robustness
健壮性
The primary objective of HDFS is to store data reliably even in thepresence of failures. The three common types of failures are Namenodefailures, Datanode failures and network partitions.
The primary objective of HDFS is to store data reliably even in thepresence of failures. The three common types of failures are Namenodefailures, Datanode failures and network partitions.
Data Disk Failure, Heartbeats and Re-Replication
磁盘错误, 心跳 and 再复制
Each Datanode sends a Heartbeat message to the Namenodeperiodically. A network partition can cause a subset of Datanodes tolose connectivity with the Namenode. The Namenode detects thiscondition by the absence of a Heartbeat message. The Namenode marksDatanodes without recent Heartbeats as dead and does not forward anynew IOrequests to them. Any data that was registered to a dead Datanode isnot available to HDFS any more. Datanode death may cause thereplication factor of some blocks to fall below their specified value.The Namenode constantly tracks which blocks need to be replicated andinitiates replication whenever necessary. The necessity forre-replication may arise due to many reasons: a Datanode may becomeunavailable, a replica may become corrupted, a hard disk on a Datanodemay fail, or the replication factor of a file may be increased.
Each Datanode sends a Heartbeat message to the Namenodeperiodically. A network partition can cause a subset of Datanodes tolose connectivity with the Namenode. The Namenode detects thiscondition by the absence of a Heartbeat message. The Namenode marksDatanodes without recent Heartbeats as dead and does not forward anynew IOrequests to them. Any data that was registered to a dead Datanode isnot available to HDFS any more. Datanode death may cause thereplication factor of some blocks to fall below their specified value.The Namenode constantly tracks which blocks need to be replicated andinitiates replication whenever necessary. The necessity forre-replication may arise due to many reasons: a Datanode may becomeunavailable, a replica may become corrupted, a hard disk on a Datanodemay fail, or the replication factor of a file may be increased.
Cluster Rebalancing
全局负载平衡
The HDFS architecture is compatible with data rebalancing schemes.A scheme might automatically move data from one Datanode to another ifthe free space on a Datanode falls below a certain threshold. In theevent of a sudden high demand for a particular file, a scheme mightdynamically create additional replicas and rebalance other data in thecluster. These types of data rebalancing schemes are not yetimplemented.
The HDFS architecture is compatible with data rebalancing schemes.A scheme might automatically move data from one Datanode to another ifthe free space on a Datanode falls below a certain threshold. In theevent of a sudden high demand for a particular file, a scheme mightdynamically create additional replicas and rebalance other data in thecluster. These types of data rebalancing schemes are not yetimplemented.
Data Integrity
数据完整性
<!-- --> It ispossible that a block of data fetched from a Datanode arrivescorrupted. This corruption can occur because of faults in a storagedevice, network faults, or buggy software. The HDFS client softwareimplements checksum checking on the contents of HDFS files. When aclient creates an HDFS file, it computes a checksum of each block ofthe file and stores these checksums in a separate hidden file in thesame HDFS namespace. When a client retrieves file contents it verifiesthat the data it received from each Datanode matches the checksumstored in the associated checksum file. If not, then the client can optto retrieve that block from another Datanode that has a replica of thatblock.
<!-- --> It ispossible that a block of data fetched from a Datanode arrivescorrupted. This corruption can occur because of faults in a storagedevice, network faults, or buggy software. The HDFS client softwareimplements checksum checking on the contents of HDFS files. When aclient creates an HDFS file, it computes a checksum of each block ofthe file and stores these checksums in a separate hidden file in thesame HDFS namespace. When a client retrieves file contents it verifiesthat the data it received from each Datanode matches the checksumstored in the associated checksum file. If not, then the client can optto retrieve that block from another Datanode that has a replica of thatblock.
Metadata Disk Failure
元数据磁盘故障
The FsImage and the EditLog are central data structures of HDFS. Acorruption of these files can cause the HDFS instance to benon-functional. For this reason, the Namenode can be configured tosupport maintaining multiple copies of the FsImage and EditLog. Anyupdate to either the FsImage or EditLog causes each of the FsImages andEditLogs to get updated synchronously. This synchronous updating ofmultiple copies of the FsImage and EditLog may degrade the rate ofnamespace transactions per second that a Namenode can support. However,this degradation is acceptable because even though HDFS applicationsare very dataintensive in nature, they are not metadataintensive. When a Namenode restarts, it selects the latest consistent FsImage and EditLog to use.
FsImage和EditLog是HDFS中心的数据结构. 这些文件中一个损毁阿会引起HDFS实例的不能正常工作. 因为这个原因,名字节点能够被设置为支持维护多个FsImage和EditLog的副本.任何一个FsImage或EditLog更新了,引起其他的FsImages和EditLogs都同步更新了.这个同步更新FsImage、EditLog多个copy的机制,会减少名字节点每秒处理事务的数量. 无论如何,这个损失是可以被接受的,因为即使HDFS应用程序的运算速度是非常重要的,但也没有元数据重要. 当名字节点重起,它选择最新,且数据一致的FsImage和EditLog被使用.
The Namenode machine is a single point of failure for an HDFScluster. If the Namenode machine fails, manual intervention isnecessary. Currently, automatic restart and failover of the Namenodesoftware to another machine is not supported.
名字节点服务器是HDFS群集中的一个单点故障点. 假如名字节点失效了, 人工的操作是必须的. 在当前, 自动重起并且修复错误,自动将名字节点软件部署到另外一台机器还没有被支持。
Snapshots
数据快照
Snapshots support storing a copy of data at a particular instant oftime. One usage of the snapshot feature may be to roll back a corruptedHDFS instance to a previously known good point in time. HDFS does notcurrently support snapshots but will in a future release.
快照支持存储一个分布式文件系统某个时间的一份copy数据。快照的用处是可以回滚HDFS实例到之前好的状态点。HDFS现在还不支持快照,但是以后版本打算支持.
Data Organization
数据组织
Data Blocks
数据块
HDFS is designed to support very large files. Applications that arecompatible with HDFS are those that deal with large data sets. Theseapplications write their data only once but they read it one or moretimes and require these reads to be satisfied at streaming speeds. HDFSsupports write-once-read-many semantics on files. A typical block sizeused by HDFS is 64 MB. Thus, an HDFS file is chopped up into 64 MBchunks, and if possible, each chunk will reside on a differentDatanode.
HDFS被设计为支持非常大的文件. 在HDFS运行的软件都是处理大数据集的.这些应用程序一般写一次数据,但是可能需要顺畅的对那些数据读一次或多次. HDFS支持写一次读多次的文件语义.一个典型的HDFS文件块大小是64MB. 应次, 一个HDFS文件被分割成64MB大小的数据块集合, 如果可能,每一个块可以在不同的数据节点上。
Staging
分段运输
A client request to create a file does not reach the Namenodeimmediately. In fact, initially the HDFS client caches the file datainto a temporary local file. Application writes are transparentlyredirected to this temporary local file. When the local fileaccumulates data worth over one HDFS block size, the client contactsthe Namenode. The Namenode inserts the file name into the file systemhierarchy and allocates a data block for it. The Namenode responds tothe client request with the identity of the Datanode and thedestination data block. Then the client flushes the block of data fromthe local temporary file to the specified Datanode. When a file isclosed, the remaining un-flushed data in the temporary local file istransferred to the Datanode. The client then tells the Namenode thatthe file is closed. At this point, the Namenode commits the filecreation operation into a persistent store. If the Namenode dies beforethe file is closed, the file is lost.
A client request to create a file does not reach the Namenodeimmediately. In fact, initially the HDFS client caches the file datainto a temporary local file. Application writes are transparentlyredirected to this temporary local file. When the local fileaccumulates data worth over one HDFS block size, the client contactsthe Namenode. The Namenode inserts the file name into the file systemhierarchy and allocates a data block for it. The Namenode responds tothe client request with the identity of the Datanode and thedestination data block. Then the client flushes the block of data fromthe local temporary file to the specified Datanode. When a file isclosed, the remaining un-flushed data in the temporary local file istransferred to the Datanode. The client then tells the Namenode thatthe file is closed. At this point, the Namenode commits the filecreation operation into a persistent store. If the Namenode dies beforethe file is closed, the file is lost.
The above approach has been adopted after careful consideration oftarget applications that run on HDFS. These applications need streamingwrites to files. If a client writes to a remote file directly withoutany client side buffering, the network speed and the congestion in thenetwork impacts throughput considerably. This approach is not withoutprecedent. Earlier distributed file systems, e.g. AFS,have used client side caching to improve performance. A POSIXrequirement has been relaxed to achieve higher performance of datauploads.
The above approach has been adopted after careful consideration oftarget applications that run on HDFS. These applications need streamingwrites to files. If a client writes to a remote file directly withoutany client side buffering, the network speed and the congestion in thenetwork impacts throughput considerably. This approach is not withoutprecedent. Earlier distributed file systems, e.g. AFS,have used client side caching to improve performance. A POSIXrequirement has been relaxed to achieve higher performance of datauploads.
Replication Pipelining
管道方式的复制操作
When a client is writing data to an HDFS file, its data is firstwritten to a local file as explained in the previous section. Supposethe HDFS file has a replication factor of three. When the local fileaccumulates a full block of user data, the client retrieves a list ofDatanodes from the Namenode. This list contains the Datanodes that willhost a replica of that block. The client then flushes the data block tothe first Datanode. The first Datanode starts receiving the data insmall portions (4 KB), writes each portion to its local repository andtransfers that portion to the second Datanode in the list. The secondDatanode, in turn starts receiving each portion of the data block,writes that portion to its repository and then flushes that portion tothe third Datanode. Finally, the third Datanode writes the data to itslocal repository. Thus, a Datanode can be receiving data from theprevious one in the pipeline and at the same time forwarding data tothe next one in the pipeline. Thus, the data is pipelined from oneDatanode to the next.
当一个客户端写数据到HDFS文件时,数据前面一段先写入本地文件. 假设,HDFS文件的副本参数为3.当本地文件累计到满一个数据块时,客户端从名字节点得到一个数据节点列表.这些数据节点将存放这个数据块的一个副本.接着,客户端刷新数据到第一个数据节点. 第一个数据节点开始接收数据,一小块一小块接收(4K),将每一小块的数据写到本地存储,同时将这一小块数据传输到列表上的第二个数据节点上. 第二个数据节点,继续接受数据写到本地存储,接着传输到第三个数据节点上。最后第三节点将数据写到它的本地存储上。就这样,一个数据节点能够从管道的前一个接收数据,同时又将数据传给管道中的下一个节点,就这样数据在管道中从一个数据节点传送到另一个数据节点。
Accessibility
访问方式
HDFS can be accessed from applications in many different ways. Natively, HDFS provides a Java APIfor applications to use. A C language wrapper for this Java API is alsoavailable. In addition, an HTTP browser can also be used to browse thefiles of an HDFS instance. Work is in progress to expose HDFS throughthe WebDAVprotocol.
应用能够通过多总方式访问HDFS. 原生接口, HDFS提供Java 应用程序接口. C语言包装的Java 应用程序接口. 另外, 浏览器能够HDFS上的文件. Work is in progress to expose HDFS through the WebDAVprotocol.
DFSShell
分布式文件系统命令行接口
HDFS allows user data to be organized in the form of files and directories. It provides a commandline interface called DFSShellthat lets a user interact with the data in HDFS. The syntax of thiscommand set is similar to other shells (e.g. bash, csh) that users arealready familiar with. Here are some sample action/command pairs:
HDFS允许用户数据被组织成文件和目录的形式. 提供的命令行形式的接口叫DFSShell,是用户和HDFS中数据交互的一种接口. 语法有点像其他用户已经熟悉的命令行环境(例如 bash, csh). 这里提供一些功能和命令的例子:
Action 功能 Command 命令 Create a directory named /foodir bin/hadoop dfs -mkdir /foodir 建立一个目录 /foodir bin/hadoop dfs -mkdir /foodir View the contents of a file named /foodir/myfile.txt bin/hadoop dfs -cat /foodir/myfile.txt查看/foodir/myfile.txt文件的内容 bin/hadoop dfs -cat /foodir/myfile.txt DFSShell is targeted for applications that need a scripting language to interact with the stored data.
DFSShell的目的是为了应用程序通过脚本访问HDFS中的数据.
DFSAdmin
管理工具
The DFSAdmincommand set is used foradministering an HDFS cluster. These are commands that are used only byan HDFS administrator. Here are some sample action/command pairs:
DFSAdmin的一组命令是用于管理HDFS群集. 这些命令主要给HDFS管理员使用. 这里提供一些功能和命令的例子:
Action 功能Command 命令 Put a cluster in SafeMode (设置群集进入安全模式) bin/hadoop dfsadmin -safemode enter Generate a list of Datanodes (产生一个数据节点列表) bin/hadoop dfsadmin -report Decommission Datanode datanodename bin/hadoop dfsadmin -decommission datanodename 使数据节点datanodename推出 bin/hadoop dfsadmin -decommission datanodename Browser Interface
浏览器接口
A typical HDFS install configures a web server to expose the HDFSnamespace through a configurable TCP port. This allows a user tonavigate the HDFS namespace and view the contents of its files using aweb browser.
一个典型的HDFS安装通过一个可配置的端口的网站服务器来暴露HDFS名字空间. 他允许用户浏览HDFS名字空间和浏览通过浏览器浏览文件.
Space Reclamation
空间的回收
File Deletes and Undeletes
文件的删除和恢复
When a file is deleted by a user or an application, it is notimmediately removed from HDFS. Instead, HDFS first renames it to a filein the /trashdirectory. The file can be restored quickly as long as it remains in /trash. A file remains in /trashfor a configurable amount of time. After the expiry of its life in /trash,the Namenode deletes the file from the HDFS namespace. The deletion ofa file causes the blocks associated with the file to be freed. Notethat there could be an appreciable time delay between the time a fileis deleted by a user and the time of the corresponding increase in freespace in HDFS.
当一个文件被用户删除,它没有立即被HDFS文件系统删除. HDFS先把它改名到/trash目录.文件只要在 /trash中,就能被快速的恢复. 文件在 /trash保留一定的时间,是可以配置的. 当超过了/trash的生命周期, 名字服务器将会删除这个文件. 然后文件的空间被释放. 文件的删除到HDFS存储空间的增加会有一些延时.
A user can Undelete a file after deleting it as long as it remains in the /trashdirectory. If a user wants to undelete a file that he/she has deleted, he/she can navigate the /trashdirectory and retrieve the file. The /trashdirectory contains only the latest copy of the file that was deleted. The /trashdirectory is just like any other directory with one special feature:HDFS applies specified policies to automatically delete files from thisdirectory. The current default policy is to delete files from /trashthat are more than 6 hours old. In the future, this policy will be configurable through a well defined interface.
只要文件在/trash目录中,文件就能被恢复. 用户如果想恢复/trash目录中的文件,只需直接访问/trash这个路径。/trash目录仅仅包含最近删除文件的copy. /trash和其他文件一样仅仅多了一个特性: HDFS有一个自动删除其中文件的策略. 当前的策略是,删除的文件在/trash中,保留6个小时. 以后,这个策略将会通过一个良好的接口(配置文件)配置.
Decrease Replication Factor
减少复制因子
When the replication factor of a file is reduced, the Namenode selectsexcess replicas that can be deleted. The next Heartbeat transfers thisinformation to the Datanode. The Datanode then removes thecorresponding blocks and the corresponding free space appears in t |
|