【正文】
關(guān)閉之后不需要改變簡(jiǎn)化數(shù)據(jù)一致性 ? 適合 MapReduce框架,或者 web crawler ? Commodity hardware ? 錯(cuò)誤檢測(cè)和快速、自動(dòng)的恢復(fù)是 HDFS的核心架構(gòu)目標(biāo) 1 The Design of HDFS ? Lowlatency data access ? 流式讀為主 ? 比之關(guān)注數(shù)據(jù)訪問(wèn)的低延遲,更關(guān)鍵在于數(shù)據(jù)訪問(wèn)的高吞吐量 ? arbitrary file modifications ? 嚴(yán)格要求在任何時(shí)候只有一個(gè) writer。 文件尾 ? 在異構(gòu)的軟硬件平臺(tái)間的可移植性移動(dòng)計(jì)算 ? Java編寫(xiě) 2 HDFS Concepts ? blocks ? Namenodes and Datanodes ? The CommandLine Interface ? 通信接口 HDFS Conceptsblocks ? files in HDFS are broken into blocksized chunks(64 MB by default) 1. 減少元數(shù)據(jù)的量 2. 有利于順序讀寫(xiě)(在磁盤(pán)上數(shù)據(jù)順序存放) 3. 副本的默認(rèn)數(shù)目是 3 ? a file can be larger than any single disk in the work. ? making the unit of abstraction a block rather than a file simplifies the storage subsystem. HDFS ConceptsNamenodes and Datanodes ? Basic model ? Namenode ? DataNode ? 心跳機(jī)制 HDFS ConceptsNamenodes and Datanodes Basic model ? Basic model: ? Master / Slaves / Client ? Corresponding implementation: Master– NameNode Slaves–DataNodes Client –DFSClient HDFS ConceptsNamenodes and Datanodes Basic model ? 查看塊信息 hadoop fsck –files –blocks ? 部分運(yùn)行結(jié)果 HDFS ConceptsNamenodes and Datanodes NameNode ? manages the filesystem namespace 元數(shù)據(jù)信息包括: ? 文件信息 ,根目錄 ? 每一個(gè)文件對(duì)應(yīng)的文件塊的信息 ? 每一個(gè)文件塊在 DataNode的信息 ? persistent state of the filesystem metadata. ? Namenode folders structure ? Namenode namespace映像文件及修改日志 ? 客戶端對(duì)文件的訪問(wèn) HDFS ConceptsNamenodes and Datanodes NameNode manages the filesystem namespace 將所有的文件和文件夾的元數(shù)據(jù)保存在一個(gè)文件系統(tǒng)樹(shù)中。系統(tǒng)啟動(dòng)的時(shí)候從 Datanode收集而成的。 HDFS ConceptsNamenodes and Datanodes NameNode persistent state of the filesystem metadata 對(duì)于任何對(duì)文件元數(shù)據(jù)產(chǎn)生修改的操作,Namenode都使用一個(gè)稱為 Editlog的事務(wù)日志記錄下來(lái)。 整個(gè)文件系統(tǒng)的 namespace,包括 block到文件的映射、文件的屬性,都存儲(chǔ)在稱為FsImage的文件中,這個(gè)文件也是放在Namenode所在系統(tǒng)的文件系統(tǒng)上 HDFS ConceptsNamenodes and Datanodes NameNode persistent state of the filesystem metadata ? 塊進(jìn)行復(fù)制的形式放置,按照塊的方式隨機(jī)選擇存儲(chǔ)節(jié)點(diǎn)。 ? layoutVersion是一個(gè)負(fù)整數(shù),保存了 HDFS的持續(xù)化在硬盤(pán)上的數(shù)據(jù)結(jié)構(gòu)的格式版本號(hào)。 ? cTime此處為 0 ? storageType表示此文件夾中保存的是元數(shù)據(jù)節(jié)點(diǎn)的數(shù)據(jù)結(jié)構(gòu)。 ? 寫(xiě)操作成功之前,修改日志都會(huì)同步 (sync)到文件系統(tǒng)。 ? 文件夾結(jié)構(gòu) ? blk_id保存的是 HDFS的數(shù)據(jù)塊,其中保存了具體的二進(jìn)制數(shù)據(jù)。 ? 對(duì)象,實(shí)現(xiàn)了 Writable接口 3 Hadoop應(yīng)用程序示例 //在 public class DFSOperator { public static void main(String[] args) { Configuration conf = new Configuration()。 Path t = new Path( FSDataOutputStream os = (t,true)。 for (i = 0 。 i++) (test)。 } catch (IOException e) { ()。 then CLASS= 4 Data Flow ? File Read ? File Write Data FlowFile Read ? 基本過(guò)程 ? 網(wǎng)絡(luò)距離 ? 優(yōu)點(diǎn) Data FlowFile Read基本過(guò)程 ? The client opens the file it wishes to read by calling open() on the FileSystem object ? Multiple DistributedFileSystem calls the namenode, using RPC, to determine the locations of the blocks for the first few blocks in the file Data FlowFile Read詳細(xì)過(guò)程 ? For