NameNode多次Format后DataNode无法启动的问题

1.NameNode格式化两次后,DataNode无法启动,查看日志,有如下错误:

2014-07-06 08:22:40,506 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed for block pool Block pool  (Datanode Uuid unassigned) service to hadoop3/192.168.56.203:9000
java.io.IOException: Cluster IDs not matched: dn cid=CID-dfdd94b3-ce12-4465-ab52-6a02b7e7dba1 but ns cid=CID-48bee819-05bb-4ad4-9f25-1aa903fbfcb7; bpid=BP-500128720-192.168.56.202-1404563273292
at org.apache.hadoop.hdfs.server.datanode.DataNode.setClusterId(DataNode.java:291)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:896)
at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:274)
at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:220)
at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:815)
at java.lang.Thread.run(Thread.java:662)

2.从错误可以看出

dn cid=CID-dfdd94b3-ce12-4465-ab52-6a02b7e7dba1 but ns cid=CID-48bee819-05bb-4ad4-9f25-1aa903fbfcb7

DataNode的Cluster ID是CID-dfdd94b3-ce12-4465-ab52-6a02b7e7dba1但是NameNode的Cluster IO是CID-48bee819-05bb-4ad4-9f25-1aa903fbfcb7

3.解决方法:修改这两个Cluster ID一致即可。

NameNode的Cluster ID 是从${dfs.namenode.name.dir}/current/VERSION文件中:

namespaceID=62152918
clusterID=CID-48bee819-05bb-4ad4-9f25-1aa903fbfcb7
cTime=0
storageType=NAME_NODE
blockpoolID=BP-1815517363-192.168.100.146-1404964076610
layoutVersion=-47

DataNode的Cluster ID是从${dfs.datanode.data.dir}/current/VERSION文件中,配置多个data目录的话,每个目录都会有这样的目录结构:

storageID=DS-914182193-192.168.100.152-50010-1404964099652
clusterID=CID-d3270dd3-4853-4dfe-95f0-87fa70399afb
cTime=0
storageType=DATA_NODE
layoutVersion=-47

将这两个ClusterID修改成一个即可。                                                                 可以将NameNode的ID修改成DataNode的ID,NameNode个数有限,DataNode数量较多,修改NameNode端工作少很多。

你可能感兴趣的:(Hadoop)