hdfs-<NameNode的format>

本文详细解析了Hadoop FSImage文件的内部结构和元数据信息,包括目录和文件的元数据,如事务序号、复制次数、修改时间、预设块大小等关键数据,为深入理解Hadoop文件系统提供了宝贵的洞察。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、在属性dfs.namenode.name.dir指定的目录中创建相应的元数据文件

a)current/VERSION

#Fri Dec 06 11:21:35 CST 2013
namespaceID=140437801
clusterID=CID-5a02557f-1977-44d6-b7bc-d124be2d0ba3
cTime=0
storageType=NAME_NODE
blockpoolID=BP-599437854-10.12.120.79-1386299958223
layoutVersion=-47


b)current/seen_txid
写入事务序号txid

0


FSImage$FSImageSaver写入current/fsimage.ckpt
然后再重命名为fsimage(+19位的txid)fsimage_0000000000000000000
1、文件头

out.writeInt(HdfsConstants.LAYOUT_VERSION);
out.writeInt(sourceNamesystem.unprotectedGetNamespaceInfo()
.getNamespaceID());
out.writeLong(fsDir.rootDir.numItemsInTree());//整个文件系统中包含有多少文件和目录
out.writeLong(sourceNamesystem.getGenerationStampV1());
out.writeLong(sourceNamesystem.getGenerationStampV2()); out.writeLong(sourceNamesystem.getGenerationStampAtblockIdSwitch());
out.writeLong(sourceNamesystem.getLastAllocatedBlockId());
out.writeLong(context.getTxId());
out.writeLong(sourceNamesystem.getLastInodeId());


2、接下来便是目录和文件的元数据信息

Map<String, INodeFileUnderConstruction> nodes =
leaseManager.getINodesUnderConstruction();
out.writeInt(nodes.size()); // write the size
for (Map.Entry<String, INodeFileUnderConstruction> entry
: nodes.entrySet()) {
FSImageSerialization.writeINodeUnderConstruction(
out, entry.getValue(), entry.getKey());
[code="java"]
writeString(path, out);
out.writeLong(cons.getId());
out.writeShort(cons.getFileReplication());
out.writeLong(cons.getModificationTime());
out.writeLong(cons.getPreferredBlockSize());

writeBlocks(cons.getBlocks(), out);
cons.getPermissionStatus().write(out);

writeString(cons.getClientName(), out);
writeString(cons.getClientMachine(), out);

out.writeInt(0); // do not store locations of last block

}
[/code]


参考:http://abloz.com/2013/01/08/hadoop-1-0-4-fsimage-file-format.html
http://blog.youkuaiyun.com/xhh198781/article/details/6904615
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值