HDFS

From HDFS: The Hadoop Distributed File System (HDFS) is designed to store very large data sets reliably, and to stream those data sets at high bandwidth to user applications.

Assumptions

  1. Hardware failure is the norm rather than the exception.

Goals

  1. HDFS is designed more for batch processing rather than interactive use by users. The emphasis is on high throughput of data access rather than low latency of data access.
  2. HDFS is tuned to support large files.
  3. The assumption is that it is often better to migrate the computation closer to where the data is located rather than moving the data to where the application is running.

NameNode and DataNode

  1. The existence of a single NameNode in a cluster greatly simplifies the architecture of the system. The NameNode is the arbitrator and repository for all HDFS metadata. The system is designed in such a way that user data never flows through the NameNode.
  2. The NameNode maintains the file system namespace. Any change to the file system namespace or its properties is recorded by the NameNode.

Data Replication

  1. The number of copies of a file is called the replication factor of that file. This information is stored by the NameNode.
  2. The block size and replication factor are configurable per file.
  3. All blocks in a file except the last block are the same size
  4. An application can specify the number of replicas of a file.
  5. The NameNode makes all decisions regarding replication of blocks. It periodically receives a Heartbeat and a Blockreport from each of the DataNodes in the cluster. Receipt of a Heartbeat implies that the DataNode is functioning properly. A Blockreport contains a list of all blocks on a DataNode.

Racks

  1. Large HDFS instances run on a cluster of computers that commonly spread across many racks. Communication between two nodes in different racks has to go through switches.
  2. For the common case, when the replication factor is three, HDFS’s placement 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 a different node in a different rack.
  3. If there exists a replica on the same rack as the reader node, then that replica is preferred to satisfy the read request. If HDFS cluster spans multiple data centers, then a replica that is resident in the local data center is preferred over any remote replica.
  4. On startup, the NameNode enters a special state called Safemode. Replication of data blocks does not occur when the NameNode is in the Safemode state.
  5. A block is considered safely replicated when the minimum number of replicas of that data block has checked in with the NameNode.
  6. The NameNode keeps an image of the entire file system namespace and file Blockmap in memory.

The Persistence of File System Metadata

  1. The NameNode uses a transaction log called the EditLog to persistently record every change that occurs to file system metadata.
  2. The entire file system namespace, including the mapping of blocks to files and file system properties, is stored in a file called the FsImage. The FsImage is stored as a file in the NameNode’s local file system too.
  3. When the NameNode starts up, it reads the FsImage and EditLog from disk, applies all the transactions from the EditLog to the in-memory representation of the FsImage, and flushes out this new version into a new FsImage on disk. It can then truncate the old EditLog because its transactions have been applied to the persistent FsImage. This process is called a checkpoint.
  4. It is not optimal to create all local files in the same directory because the local file system might not be able to efficiently support a huge number of files in a single directory.

The Communication Protocols

  1. All HDFS communication protocols are layered on top of the TCP/IP protocol.
  2. By design, the NameNode never initiates any RPCs. Instead, it only responds to RPC requests issued by DataNodes or clients.

Robustness

  1. The three common types of failures are NameNode failures, DataNode failures and network partitions.
  2. The time-out to mark DataNodes dead is conservatively long (over 10 minutes by default) in order to avoid replication storm caused by state flapping of DataNodes.
  3. A scheme might automatically move data from one DataNode to another if the free space on a DataNode falls below a certain threshold.
  4. When a client creates an HDFS file, it computes a checksum of each block of the file and stores these checksums in a separate hidden file in the same HDFS namespace. When a client retrieves file contents it verifies that the data it received from each DataNode matches the checksum stored in the associated checksum file. If not, then the client can opt to retrieve that block from another DataNode that has a replica of that block.
  5. However, this degradation is acceptable because even though HDFS applications are very data intensive in nature, they are not metadata intensive. When a NameNode restarts, it selects the latest consistent FsImage and EditLog to use.

Data Organization

  1. HDFS supports write-once-read-many semantics on files. A typical block size used by HDFS is 128 MB. Thus, an HDFS file is chopped up into 128 MB chunks, and if possible, each chunk will reside on a different DataNode.
  2. Thus, the data is pipelined from one DataNode to the next.
?著作權歸作者所有,轉載或內容合作請聯系作者
  • 序言:七十年代末巩割,一起剝皮案震驚了整個濱河市檐嚣,隨后出現的幾起案子地淀,更是在濱河造成了極大的恐慌,老刑警劉巖孵淘,帶你破解...
    沈念sama閱讀 206,126評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現場離奇詭異召噩,居然都是意外死亡父虑,警方通過查閱死者的電腦和手機该酗,發(fā)現死者居然都...
    沈念sama閱讀 88,254評論 2 382
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來士嚎,“玉大人垂涯,你說我怎么就攤上這事烁焙。” “怎么了耕赘?”我有些...
    開封第一講書人閱讀 152,445評論 0 341
  • 文/不壞的土叔 我叫張陵,是天一觀的道長膳殷。 經常有香客問我操骡,道長,這世上最難降的妖魔是什么赚窃? 我笑而不...
    開封第一講書人閱讀 55,185評論 1 278
  • 正文 為了忘掉前任册招,我火速辦了婚禮,結果婚禮上勒极,老公的妹妹穿的比我還像新娘是掰。我一直安慰自己,他們只是感情好辱匿,可當我...
    茶點故事閱讀 64,178評論 5 371
  • 文/花漫 我一把揭開白布键痛。 她就那樣靜靜地躺著,像睡著了一般匾七。 火紅的嫁衣襯著肌膚如雪絮短。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 48,970評論 1 284
  • 那天昨忆,我揣著相機與錄音丁频,去河邊找鬼。 笑死邑贴,一個胖子當著我的面吹牛席里,可吹牛的內容都是我干的。 我是一名探鬼主播拢驾,決...
    沈念sama閱讀 38,276評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼奖磁,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了独旷?” 一聲冷哼從身側響起署穗,我...
    開封第一講書人閱讀 36,927評論 0 259
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎嵌洼,沒想到半個月后案疲,有當地人在樹林里發(fā)現了一具尸體,經...
    沈念sama閱讀 43,400評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡麻养,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 35,883評論 2 323
  • 正文 我和宋清朗相戀三年褐啡,在試婚紗的時候發(fā)現自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片鳖昌。...
    茶點故事閱讀 37,997評論 1 333
  • 序言:一個原本活蹦亂跳的男人離奇死亡备畦,死狀恐怖低飒,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情懂盐,我是刑警寧澤褥赊,帶...
    沈念sama閱讀 33,646評論 4 322
  • 正文 年R本政府宣布,位于F島的核電站莉恼,受9級特大地震影響拌喉,放射性物質發(fā)生泄漏。R本人自食惡果不足惜俐银,卻給世界環(huán)境...
    茶點故事閱讀 39,213評論 3 307
  • 文/蒙蒙 一尿背、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧捶惜,春花似錦田藐、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,204評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至陪捷,卻和暖如春回窘,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背市袖。 一陣腳步聲響...
    開封第一講書人閱讀 31,423評論 1 260
  • 我被黑心中介騙來泰國打工啡直, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人苍碟。 一個月前我還...
    沈念sama閱讀 45,423評論 2 352
  • 正文 我出身青樓酒觅,卻偏偏與公主長得像,于是被迫代替她去往敵國和親微峰。 傳聞我的和親對象是個殘疾皇子舷丹,可洞房花燭夜當晚...
    茶點故事閱讀 42,722評論 2 345

推薦閱讀更多精彩內容

  • Introduction Assumptions and GoalsHardware FailureStreami...
    a6fc544968bb閱讀 440評論 0 2
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,292評論 0 10
  • 很多時候都覺得颜凯,活著好累。 有工作的時候仗扬,愁工資太少交完房租連生活費都不夠症概。 沒有工作的時候,愁吃完這頓飯下一頓怎...
    KaLee閱讀 1,335評論 6 0
  • 榆樹下被拉長的影子 掩過青草 掩過黃磚 又掩過瀝青路 指間兩朵新桃灼灼相依 只有寂靜層層浸染 金色的連翹上泛著微光...
    阿念和阿書閱讀 215評論 2 4
  • 對于眼前的情形早芭,鳳仙兒很是意外彼城,院子里的每個人都在認認真真的做自己手上的事,看上去是那么嚴陣有序、井井有條募壕,沒有一...
    兮云閱讀 473評論 0 4