NameNode存储DataNode的元数据,NameNode主要是用于维护DataNode信息。它存储在hadoop文件夹下data/dfs/name/current/,其中以fsimage开头的文件主要存储目录、文件名称及其依赖关系,以edits开头的文件主要存储尚未来得及合并的日志记录
ls hadoop/data/dfs/name/current
#-----------------------------------------------------------------------------
edits_0000000000000000001-0000000000000000002 fsimage_0000000000000000005.md5
edits_0000000000000000003-0000000000000000003 fsimage_0000000000000000014
edits_0000000000000000004-0000000000000000005 fsimage_0000000000000000014.md5
edits_0000000000000000006-0000000000000000014 seen_txid
edits_inprogress_0000000000000000015 VERSION
fsimage_0000000000000000005
#-----------------------------------------------------------------------------
#查看目录、文件名称及其依赖关系,将信息转化为xml格式
hdfs oiv -i hadoop_home/data/dfs/name/current/fsimage* -o save_path/filename -p XMl
#例程:
hdfs oiv -i /opt/software/hadoop313/data/dfs/name/current/fsimage_0000000000000000258 -o ~/fsimage_0000000000000000258 -p XML
#查看文件日志记录
hdfs oev -i hadoop_home/data/dfs/name/current/edits* -o save_path/filename -p XMl
#例程:
hdfs oev -i /opt/software/hadoop313/data/dfs/name/current/edits_inprogress_0000000000000000079 -o ~/edits_inprogress_0000000000000000079 -p XML
<fsimage>
<version>
<layoutVersion>-64layoutVersion>
<onDiskVersion>1onDiskVersion>
<oivRevision>ba631c436b806728f8ec2f54ab1e289526c90579oivRevision>
version>
<NameSection>
<namespaceId>1540392763namespaceId>
<genstampV1>1000genstampV1>
<genstampV2>1006genstampV2>
<genstampV1Limit>0genstampV1Limit>
<lastAllocatedBlockId>1073741830lastAllocatedBlockId>
<txid>44txid>
NameSection>
<ErasureCodingSection>
<erasureCodingPolicy>
<policyId>1policyId>
<policyName>RS-6-3-1024kpolicyName>
<cellSize>1048576cellSize>
<policyState>DISABLEDpolicyState>
<ecSchema>
<codecName>rscodecName>
<dataUnits>6dataUnits>
<parityUnits>3parityUnits>
ecSchema>
erasureCodingPolicy>
<erasureCodingPolicy>
<policyId>2policyId>
<policyName>RS-3-2-1024kpolicyName>
<cellSize>1048576cellSize>
<policyState>DISABLEDpolicyState>
<ecSchema>
<codecName>rscodecName>
<dataUnits>3dataUnits>
<parityUnits>2parityUnits>
ecSchema>
erasureCodingPolicy>
<erasureCodingPolicy>
<policyId>3policyId>
<policyName>RS-LEGACY-6-3-1024kpolicyName>
<cellSize>1048576cellSize>
<policyState>DISABLEDpolicyState>
<ecSchema>
<codecName>rs-legacycodecName>
<dataUnits>6dataUnits>
<parityUnits>3parityUnits>
ecSchema>
erasureCodingPolicy>
<erasureCodingPolicy>
<policyId>4policyId>
<policyName>XOR-2-1-1024kpolicyName>
<cellSize>1048576cellSize>
<policyState>DISABLEDpolicyState>
<ecSchema>
<codecName>xorcodecName>
<dataUnits>2dataUnits>
<parityUnits>1parityUnits>
ecSchema>
erasureCodingPolicy>
<erasureCodingPolicy>
<policyId>5policyId>
<policyName>RS-10-4-1024kpolicyName>
<cellSize>1048576cellSize>
<policyState>DISABLEDpolicyState>
<ecSchema>
<codecName>rscodecName>
<dataUnits>10dataUnits>
<parityUnits>4parityUnits>
ecSchema>
erasureCodingPolicy>
ErasureCodingSection>
<INodeSection>
<lastInodeId>16396lastInodeId>
<numInodes>12numInodes>
<inode>
<id>16385id>
<type>DIRECTORYtype>
<name/>
<mtime>1640743069439mtime>
<permission>root:supergroup:0755permission>
<nsquota>9223372036854775807nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16386id>
<type>DIRECTORYtype>
<name>tmpname>
<mtime>1640738001903mtime>
<permission>root:supergroup:0770permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16387id>
<type>DIRECTORYtype>
<name>hadoop-yarnname>
<mtime>1640738001903mtime>
<permission>root:supergroup:0770permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16388id>
<type>DIRECTORYtype>
<name>stagingname>
<mtime>1640738001903mtime>
<permission>root:supergroup:0770permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16389id>
<type>DIRECTORYtype>
<name>historyname>
<mtime>1640738001940mtime>
<permission>root:supergroup:0770permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16390id>
<type>DIRECTORYtype>
<name>donename>
<mtime>1640738001903mtime>
<permission>root:supergroup:0770permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16391id>
<type>DIRECTORYtype>
<name>done_intermediatename>
<mtime>1640738001940mtime>
<permission>root:supergroup:1777permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16392id>
<type>DIRECTORYtype>
<name>testname>
<mtime>1640743069439mtime>
<permission>root:supergroup:0755permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16393id>
<type>DIRECTORYtype>
<name>kb16name>
<mtime>1640743124723mtime>
<permission>root:supergroup:0755permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16394id>
<type>DIRECTORYtype>
<name>hadoopname>
<mtime>1640743625760mtime>
<permission>root:supergroup:0755permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16395id>
<type>DIRECTORYtype>
<name>hivename>
<mtime>1640743124723mtime>
<permission>root:supergroup:0755permission>
<nsquota>-1nsquota>
<dsquota>-1dsquota>
inode>
<inode>
<id>16396id>
<type>FILEtype>
<name>ratings.csvname>
<replication>1replication>
<mtime>1640743625739mtime>
<atime>1640743618694atime>
<preferredBlockSize>134217728preferredBlockSize>
<permission>root:supergroup:0644permission>
<blocks>
<block>
<id>1073741825id>
<genstamp>1001genstamp>
<numBytes>134217728numBytes>
block>
<block>
<id>1073741826id>
<genstamp>1002genstamp>
<numBytes>134217728numBytes>
block>
<block>
<id>1073741827id>
<genstamp>1003genstamp>
<numBytes>134217728numBytes>
block>
<block>
<id>1073741828id>
<genstamp>1004genstamp>
<numBytes>134217728numBytes>
block>
<block>
<id>1073741829id>
<genstamp>1005genstamp>
<numBytes>134217728numBytes>
block>
<block>
<id>1073741830id>
<genstamp>1006genstamp>
<numBytes>7172347numBytes>
block>
blocks>
<storagePolicyId>0storagePolicyId>
inode>
INodeSection>
<INodeReferenceSection/>
<SnapshotSection>
<snapshotCounter>0snapshotCounter>
<numSnapshots>0numSnapshots>
SnapshotSection>
<INodeDirectorySection>
<directory>
<parent>16385parent>
<child>16392child>
<child>16386child>
directory>
<directory>
<parent>16386parent>
<child>16387child>
directory>
<directory>
<parent>16387parent>
<child>16388child>
directory>
<directory>
<parent>16388parent>
<child>16389child>
directory>
<directory>
<parent>16389parent>
<child>16390child>
<child>16391child>
directory>
<directory>
<parent>16392parent>
<child>16393child>
directory>
<directory>
<parent>16393parent>
<child>16394child>
<child>16395child>
directory>
<directory>
<parent>16394parent>
<child>16396child>
directory>
INodeDirectorySection>
<FileUnderConstructionSection/>
<SecretManagerSection>
<currentId>0currentId>
<tokenSequenceNumber>0tokenSequenceNumber>
<numDelegationKeys>0numDelegationKeys>
<numTokens>0numTokens>
SecretManagerSection>
<CacheManagerSection>
<nextDirectiveId>1nextDirectiveId>
<numDirectives>0numDirectives>
<numPools>0numPools>
CacheManagerSection>
fsimage>
<EDITS>
<EDITS_VERSION>-64EDITS_VERSION>
<RECORD>
<OPCODE>OP_START_LOG_SEGMENTOPCODE>
<DATA>
<TXID>45TXID>
DATA>
RECORD>
EDITS>