大数据系列(二):HDFS(Hadoop分布式文件系统)(一)

HDFS设计

HDFS is a filesystem designed for storing very large files with streaming data access patterns, running on clusters of commodity hardware.

HDFS不适用的情况<p>
  • 低时间延迟的数据访问(Low-latency data access)
    HDFS 是为高吞吐量应用优化的,这会导致它的高延迟性(Remember, HDFS is optimized for delivering a high throughput of data, and this may be at the expense of latency)
  • 大量的小文件
    由于namenode将文件系统的元数据存储在内存中,因此该文件系统所能存储的文件总数受限于namenode的内存容量。每个文件、目录和数据块的存储信息大约占150B,数十亿的文件存储会有问题(Since the namenode holds filesystem metadata in memory, the limit to the number of files in a filesystem is governed by the amount of memory on the namenode. As a rule of thumb, each file, directory, and block takes about 150 bytes。While storing millions of files is feasible, billions is beyond the capability of current hardware)
  • 多用户写入,任意修改文件
    HDFS中的文件可能只有一个writter (Files in HDFS may be written to by a single writer)

HDFS概念<p>

数据块(block)<p>

数据块(block):是最小可读写数据的数量(is the minimum amount of data that it can read or write.)HDFS也拥有数据块,默认值为64MB。HDFS上的文件也被划分为块大小(block-sized)的分块(chunks),作为独立的储存单元。

为什么HDFS的一个数据块如此大(Why Is a Block in HDFS So Large?)<p>
  • 和硬盘数据块相比,HDFS数据块大的原因是为了最小化寻址开销(HDFS blocks are large compared to disk blocks, and the reason is to minimize the cost of seeks.)**

  • 通过将块设置的足够大,从磁盘传输数据的时间可以明显大于定位这个块的开始位置所需的时间。这样,传输一个有多个块组成的文件的时间取决于磁盘传输速率(By making a block large enough, the time to transfer the data from the disk can be made to be significantly larger than the time to seek to the start of the block. Thus the time to transfer a large file made of multiple blocks operates at the disk transfer rate.)

  • 比如,寻址时间10ms左右,而传输速率为100MB/s,为了使寻址速率占传输时间的1%,块的大小需要是100MB左右(if the seek time is around 10 ms, and the transfer rate is 100 MB/s, then to make the seek time 1% of the transfer time, we need to make the block size around 100 MB)

优势<p>
  • 文件的所有块不需要存储在同一个磁盘上,因此它们可以利用集群上的任意磁盘进行存储(There’s nothing that requires the blocks from a file to be stored on the same disk, so they can take advantage of any of the disks in the cluster)
  • 使用抽象块而非整个文件作为存储单元,大大简化了存储子系统的设计(making the unit of abstraction a block rather than a file simplifies the storage subsystem)
    • 将存储子系统控制单元设置为块,可简化存储管理(单个磁盘能存储多少块相对容易)(since blocks are a fixed size, it is easy to calculate how many can be stored on a given disk)
    • 消除对元数据的顾虑(块只是存储数据的一部分,而文件的元数据,并不需要一起存储。这样,其他系统可以单独管理这些元数据)(blocks are just a chunk of data to be stored—file metadata such as permissions information does not need to be stored with the blocks, so another system can handle metadata separately)
  • 块非常适合用于数据备份进而提供数据容错能力和可用性,一般为3份(blocks fit well with replication for providing fault tolerance and availability)

Namenode and datanode <p>

一个HDFS集群有两类节点,以管理-工作形式运行,即一个namenode(管理者)和多个datanode(工作者)(An HDFS cluster has two types of node operating in a master-worker pattern: a namenode (the master) and a number of datanodes (workers).)

Namenode
  • The namenode manages the filesystem namespace. It maintains the filesystem tree and the metadata for all the files and directories in the tree (namenode管理文件系统的命名空间,维持文件系统树和树里所有文件和目录的元数据)。This information is stored persistently on the local disk in the form of two files: the namespace image and the edit log.(这些信息永久以两类文件(命名空间镜像文件和编制日志文件)储存在本地硬盘。)
  • The namenode also knows the datanodes on which all the blocks for a given file are located, however, it does not store block locations persistently, since this information is reconstructed from datanodes when the system starts.(namenode也记录每个文件中各个块所在的数据节点信息,但它并不永久保存块的信息,因为这些信息会在系统启动时由数据节点重建)
Datanodes <p>

Datanodes store and retrieve blocks when they are told to (by clients or the namenode), and they report back to the namenode periodically with lists of that they are storing.(Datanodes存储并检索数据块(受客户端和namenode调度),并定期向namenode发送它储存的块的列表)

HDFS Federation <p>

The namenode keeps a reference to every file and block in the filesystem in memory, which means that on very large clusters with many files, memory becomes the limiting factor for scaling. HDFS Federation allows a cluster to scale by adding namenodes, each of which manages a portion of the filesystem namespace. (namenode和内存文件系统中每个文件和数据块保持关联,这意味着在多文件的大集群上,内存会限制规模化的增长。HDFS Federation 允许一个集群通过增加namenodes实现规模化,每一个namenode管理命名空间文件系统的一部分)

Under federation, each namenode manages a namespace volume, which is made up of the metadata for the namespace, and a block pool containing all the blocks for the files in the namespace(在Federation体制下,每个namenode管理一个在命名空间组成元数据的namespace volume和一个包括命名空间文件所有数据块的block pool)

  • Namespace volumes are independent of each other, which means namenodes do not communicate with one another (Namespace volumes 相互独立,意味着namenodes之间并无联系)
  • Block pool storage is not partitioned, however, so datanodes register with each namenode in the cluster and store blocks from multiple block pools.

HDFS High-Availability <p>

The combination of replicating namenode metadata on multiple filesystems, and using the secondary namenode to create checkpoints protects against data loss, but does not provide high-availability of the filesystem. The namenode is still a single point of failure (SPOF).(在多个文件系统上复制namenode元数据并使用第二namenode来建立检查点可以防止数据丢失,但并没有提供高有效性。namenode依旧是SPOF)

To support HDFS High-Availability, there is a pair of namenodes in an active standby configuration. In the event of the failure of the active namenode, the standby takes over its duties to continue servicing client requests without a significant interruption. (为了支持HA, 会有备用的namenodes待命。如果活动的namenode失效,这些备用可以继续工作避免明显的中断)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • HDFS的设计目标 通过上一篇文章的介绍我们已经了解到HDFS到底是怎样的东西,以及它是怎样通过多副本机制来提供高...
    陌上疏影凉阅读 5,302评论 0 3
  • 首先,我们在使用前先看看HDFS是什麽?这将有助于我们是以后的运维使用和故障排除思路的获得。 HDFS采用mast...
    W_Bousquet阅读 9,749评论 0 2
  • 设计师可能是这个世界上最需要灵感的人,我们涉猎的知识五花八门,每天的阅读量无穷无尽,没事就右键另存张图片简直就是一...
    非也非也阅读 14,585评论 33 498
  • 我说我喜欢天上的云朵,白色的彩色的我都喜欢。我想偷偷摘一朵,它要带着我一个筋斗十万八千里,它要生长,长得...
    是狗是雅婷阅读 1,170评论 0 0
  • 这几年,我身边很多朋友都加入了慈善事业,我非常欣赏他们,因为他们都非常善良,而我的蜂舞人间,也一直在做慈善事业,公...
    米丽8316阅读 3,526评论 2 1