2026-10-31·by Sijie Wang

hdfs

HDFS overview: one NameNode ledger, DataNodes holding blocks, clients reading data directly from DataNodes; CP by design, HA as active-standby.

HDFS:一本账、很多盘,数据直接找 DataNode 拿

它是什么。 HDFS 是 Hadoop 分布式文件系统:把非常大的文件切开、存在很多台便宜机器上,让很多客户端并行读。它是为海量数据、单个文件本身就很大、以顺序读整文件为主、硬件天天会坏的场景生的,不是为很多小文件、低延迟随机访问、原地反复改写生的。

先看全貌。 只有三个角色。NameNode 只管账本:有哪些文件、每个文件由哪些块组成、每块在哪些 DataNode 上。DataNode 只存真正的数据。客户端先问 NameNode 要地址,再直接找 DataNode 拿数据,数据永远不经过 NameNode。

一致性定性:CP。 元数据只有一台逻辑权威。有了 HA 也只是物理上主备两台,不是 AP 系统:同一时间仍然只有一个 active 写者,分区时少数一侧宁可不可用,也不会把元数据账本写分叉。HA 缩短的是恢复时间,不是让分裂两侧都能写。

目录。 origin-and-motivation、block-size-and-metadata-math、namenode、ledger-persistence、datanode-heartbeat-and-death、writer-lease、safe-mode、ha-and-fencing、read-path、write-path、small-files、federation

about this entry

One of sijie's wiki entries. The AI on this site is grounded in the same corpus and answers in sijie's voice, with citations back to entries like this one — answering costs sijie money, so it waits behind a code: enter an access code →

hdfs — Sijie Wang