1. 程式人生 > >hadoop學習筆記肆--元資料管理機制

hadoop學習筆記肆--元資料管理機制

1、首先,認識幾個名詞

    (1)、NameNode中讀、寫、以及DataNode對映等資訊叫做“元資料” ,NameNode元資料存放位置有、記憶體、fsimage、edits log三個位置。

    (2)、edits log:記錄當前最新的元資料。

       (3)、元資料記憶體:實際在用的元資料。

    (4)、fsimage:元資料記憶體實體檔案,fsimage與NameNode內容是是一樣的(最全元資料)

          當edits log檔案大小達到閾值,會將edits log元資料寫入到fsimage檔案,並清除edits log中的元資料。

2、NameNode管理元資料方式

    (1)、客戶端上傳檔案時NameNode首先會向edits log檔案中記錄元資料資訊。

    (2)、客戶端上傳檔案,完成後返回成功資訊到NameNode,NameNode將本次上傳操作產生新的元資料資訊寫入到記憶體中。 

    (3)、每當editslog檔案寫滿時,SecondeNameNode會將editslog中的元資料同步合併到fsimage中,且清空editslog

3、SecondeNameNode對editslog、fsimage檔案同步合併方式

    (1)、當editslog檔案寫滿時,NameNode向SecondeNameNode發出請求,通知SecondeNameNode進行檔案editslog與fsimage合併。

    (2)、SecondeNameNode做出響應,並通知NameNode建立新檔案edits.new,且向edits.new檔案寫入元資料

    (3)、SecondeNameNode下載editslog、fsimage檔案到SecondeNameNode主機

    (4)、SecondeNameNode將下載editslog、fsimage檔案做同步合併合併檔案為:fsimage.chkpoint

    (5)、將合併檔案fsimage.chepoint上傳到NameNode中fsimage同目錄

    (6)、重新命名fsimage.chepoint檔案為fsimage

    (7)、重新命名edits.new為edits

                      不得不說,為了保證元資料的完整性,可靠性hadoop開發者沒少下功夫