hadoop分析之一HDFS元資料解析

2021-08-27 02:29:54 字數 2269 閱讀 4354

1、元資料(metadata):維護hdfs檔案系統中檔案和目錄的資訊,分為記憶體元資料和元資料檔案兩種。namenode維護整個元資料。

hdfs實現時,沒有採用定期匯出元資料的方法,而是採用元資料映象檔案(fsimage)+日子檔案(edits)的備份機制。

2、block:檔案內容而言。

尋路徑流程:

路徑資訊 bocks triplets

client ------------》inode---------------------》blockinfo --------------------------》datanode。

inode:檔案的基本元素:檔案和目錄

blockinfo: 檔案內容物件

datanodedescriptor:具體儲存物件。

3 、 fsimage和edits的checkpoint。fsimage有2個狀態,分別是fsimage和fsimage.ckpt,後者表示正在checkpoint的過程中,上傳後將會修改為fsimage檔案,同理edits也有兩個狀態,edits和edits.new。

4、namenode format情景分析:

private static boolean format( configuration conf ,

boolean isconfirmationneeded )

throws ioexception

while(system .in .read () != '\n') ; // discard the enter-key}}

fsnamesystem nsys = new fsnamesystem (new fsimage(dirstoformat ,

editdirstoformat ), conf) ;

nsys.dir.fsimage .format ();

return false;

}

fsnamesystem( fsimage fsimage, configuration conf ) throws ioexception 

fsimage( collection< uri> fsdirs , collection< uri> fseditsdirs )

throws ioexception

void setstoragedirectories(collection fsnamedirs,

collection< uri> fseditsdirs ) throws ioexception

}namenodedirtype dirtype = (isalsoedits ) ?

namenodedirtype .image_and_edits :

namenodedirtype .image ;

// add to the list of storage directories, only if the

// uri is of type file://

if(dirname .getscheme (). compareto( journaltype.file .name (). tolowercase())

== 0)

}// add edits dirs if they are different from name dirs

for (uri dirname : fseditsdirs )

}

public void format () throws ioexception 

}

void format(storagedirectory sd ) throws ioexception  finally 

log.info ("storage directory " + sd. getroot()

+ " has been successfully formatted.");

}

最後分析一下元資料應用的場景:

1、格式化時。

2、hadoop啟動時。

3、元資料更新操作時。

4、如果namenode與secondary namenode、backup node或checkpoint node配合使用時,會進行checkpoint操作。

hadoop分析之一HDFS元資料解析

1 元資料 metadata 維護hdfs檔案系統中檔案和目錄的資訊,分為記憶體元資料和元資料檔案兩種。namenode維護整個元資料。hdfs實現時,沒有採用定期匯出元資料的方法,而是採用元資料映象檔案 fsimage 日子檔案 edits 的備份機制。2 block 檔案內容而言。尋路徑流程 路...

Hadoop 學習總結之一 HDFS簡介

資料節點是檔案系統中真正儲存資料的地方。從元資料節點 secondary namenode 1.2.1 元資料節點資料夾結構 1.2.2 檔案系統命名空間映像檔案及修改日誌 1.2.3 從元資料節點的目錄結構 1.2.4 資料節點的目錄結構 當客戶端結束寫入資料,則呼叫stream的close函式。...

Hadoop 學習總結之一 HDFS簡介

資料節點是檔案系統中真正儲存資料的地方。從元資料節點 secondary namenode 1.2.1 元資料節點資料夾結構 1.2.2 檔案系統命名空間映像檔案及修改日誌 1.2.3 從元資料節點的目錄結構 1.2.4 資料節點的目錄結構 當客戶端結束寫入資料,則呼叫stream的close函式。...