2014-09-30 98 views
1

據我所知,在主節點我們有名稱節點,它維護兩個文件中的元數據。一個是FSImage,另一個是編輯日誌。
因此,這個FSImage在hadoop系統啓動時初始加載,並且此FSImage包含存儲的簇和數據的目錄結構。然後,對於每個發生的事務,編輯日誌文件都會更新。Hadoop - HDFS Namenode元數據 - FSImage

我的問題有以下幾點:

  1. 這些是隻包含的所有信息(的FsImage和EditLogs)還是有更多的文件?
  2. 這是否意味着FSImage文件只會被寫入一次?
  3. 如果是,那麼它爲什麼總是被複制到輔助名稱節點?它不是在增加一項任務來完成嗎?
  4. 假設我在hdfs中添加或刪除了一個新文件;那麼這個FSImage會不會被更新?
+0

我覺得這本身http://stackoverflow.com/questions/24288942/hadoop-namenode-metadata-fsimage-and-edit-logs回答幾個你的問題。 – blackSmith 2014-09-30 13:53:49

回答

0
1) Yes only these two files are there . 

    2) This is true for name node . 

    3) It is copied to secondary name node for persistent storage , things would work fine un till name node is up ,lets say you have done so many changes like creating directories ,files ,putting the data to hdfs and so on so during run time this information is directly loaded into the memory but what if namenode goes down so what ever new meta information was there which is not embedded current fsimage ,it would get lost permanently because when ever your system would come up it would load the fsimage into memory since its the old fsimage it won't have new changes . With this secondary name node we are preserving this changes in edit.log and finally edit.log file used for fsimage and new fsimage can be replaced with old one . 
    4) process is when ever meta data gets changes ,this event gets written in edit.log file and after some specified interval these logs copied to secondary name node when their size gets too big then edit.log information is flushed into the form of fsimage. 
current fsimage would not get updated with addition or deletion of file ,these changes will directly cater in memory. 
2

要理解這一點,我們必須要經過它的細節,一步一個腳印,當Hadoop是加載的FsImage運行後

  1. 名稱節點已經在數據的整個快照存儲在內存中。

  2. 交易即將到來,信息存儲在編輯日誌中。

  3. 定期地,每隔默認值每隔一小時,檢查點節點/輔助名稱節點檢索日誌,並將它們與最新的fsimage合併並將數據保存爲檢查點。 此時,nn在內存中有圖像,編輯日誌被清空,最新檢查點作爲圖像存儲在snn/cn上。

回答你的問題。

  1. 是的,只有兩個文件

  2. 在SNN/CN的的FsImage將定期更新。當導入檢查點時,NN上的fsimage將被更新。這應該至少在重新啓動時發生。

  3. 將editlog合併到fsimage是一個代價高昂的操作。它需要在namenode中進入安全模式才能合併數據。這不是在這樣的環境可能

  4. 刪除的日誌以及一個寫操作,因此它被保存在編輯日誌

0
  1. 是的,這些是僅有的兩個文件包含羣集文件系統信息

  2. 在名稱節點的每次重新啓動時,FSImage將寫入磁盤,並且在每個檢查點上,SNN會將FSImage寫入磁盤。在繁忙的羣集上,EditLog將快速增長。如果編輯日誌非常大,那麼下次重新啓動NN需要更長的時間。 SNN會定期合併EDITlog和FSImage。如果您的NN磁盤發生故障,SNN也將作爲FSImage的備份。

  3. 是的。 FSImage將在主內存中更新,不在磁盤中。當時的Editlog將在磁盤上更新與新的交易