HDFS = hadoop distributed file system
** NameNode** : 存儲(chǔ)元數(shù)據(jù) (metadata)。
metadata : a set of data that describes and gives information about other data.
元數(shù)據(jù) :存放別的數(shù)據(jù)的信息的數(shù)據(jù)就是元數(shù)據(jù),有點(diǎn)像Linux中的文件表
** DataNode ** : 塊存儲(chǔ)(block storage),默認(rèn)的每塊是64M,存儲(chǔ)的數(shù)據(jù)默認(rèn)會(huì)復(fù)制為三份存放以防某份掛掉,也就是提供了容錯(cuò)的功能。
DataNode聽從來自NameNode的命令,用于塊創(chuàng)建,刪除和復(fù)制。復(fù)制提供了兩個(gè)關(guān)鍵功能。容錯(cuò)(Fault Tolerance)和data locality(個(gè)人翻譯為數(shù)據(jù)局部性性,Haoop會(huì)只在需要運(yùn)行代碼的節(jié)點(diǎn)上運(yùn)行代碼)。
data locality:當(dāng)數(shù)據(jù)集存儲(chǔ)在HDFS中時(shí),它被劃分為塊并存儲(chǔ)在Hadoop集群中的DataNode上。當(dāng)在數(shù)據(jù)集執(zhí)行MapReduce作業(yè)時(shí),各個(gè)Mappers將處理這些塊(輸進(jìn)行入分片處理)。如果Mapper不能從它執(zhí)行的節(jié)點(diǎn)上獲取數(shù)據(jù),數(shù)據(jù)需要通過網(wǎng)絡(luò)從具有這些數(shù)據(jù)的DataNode拷貝到執(zhí)行Mapper任務(wù)的節(jié)點(diǎn)上(the data needs to be copied over the network from the DataNode which has the data to the DataNode which is executing the Mapper task)。假設(shè)一個(gè)MapReduce作業(yè)具有超過1000個(gè)Mapper,在同一時(shí)間每一個(gè)Mapper都試著去從集群上另一個(gè)DataNode節(jié)點(diǎn)上拷貝數(shù)據(jù),這將導(dǎo)致嚴(yán)重的網(wǎng)絡(luò)阻塞,因?yàn)樗械腗apper都嘗試在同一時(shí)間拷貝數(shù)據(jù)(這不是一種理想的方法)。因此,將計(jì)算任務(wù)移動(dòng)到更接近數(shù)據(jù)的節(jié)點(diǎn)上是一種更有效與廉價(jià)的方法,相比于將數(shù)據(jù)移動(dòng)到更接近計(jì)算任務(wù)的節(jié)點(diǎn)上(it is always effective and cheap to move the computation closer to the data than to move the data closer to the computation)。
from: [Hadoop]Hadoop上Data Locality

總結(jié):HDFS通過在多個(gè)節(jié)點(diǎn)上分割文件來提供可擴(kuò)展的大數(shù)據(jù)存儲(chǔ)。