常见错误:2、Hadoop多次格式化导致datanode无法启动

96
CoderF
0.1 2017.12.18 16:27 字数 87

hadoop namenode -format 多次格式化后,datanode启动不了

报错信息
017-12-14 05:07:57,636 INFO org.apache.hadoop.hdfs.server.datanode.DataNode: Starting BPOfferServices for nameservices: <default>
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.loadDataStorage(DataStorage.java:409)
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.addStorageLocations(DataStorage.java:388)
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:556)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1566)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1527)
        at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:327)
        at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:266)
        at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:746)
        at java.lang.Thread.run(Thread.java:745)
2017-12-14 05:07:58,922 ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed for Block pool <registering> (Datanode Uuid 63404450-ed85-4636-8eac-ea75dba1d424) service to hadoop/192.168.137.5:9000. Exiting.
java.io.IOException: All specified directories are failed to load.
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:557)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1566)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1527)
        at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:327)
        at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:266)
        at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:746)
        at java.lang.Thread.run(Thread.java:745)
注意
Incompatible clusterIDs in /tmp/hadoop-hadoop/dfs/data: namenode clusterID = CID-c80f243c-4a07-43f3-9eb8-f40d164a4520; datanode clusterID = CID-3e6fcd99-a2fe-42f3-9ccf-bc257a065eb3
1

可以看出,namenode的clusterID和datanode的clusterID不同,导致其无法启动。原因是我们多次格式化namenode导致两者id不同,无法启动。

解决方案

0.20.2版本解决方式

1、查看名称节点上(即在配置文件中配置的hadoop.tmp.dir参数路径)/usr/hadoop0.20.2/hadoop-huanghz/dfs/name/current/文件夹中VERSION文件中的namespaceid;
2、在两个数据节点修改上dfs.data.dir配置的路径下current文件夹中的VERSION文件namespaceid与名称节点保持一致

2.x版本解决

/data/hadoop/dfs/name/current/VERSION
用name下面的clusterID,修改datanode的/data/hadoop/dfs/data/current/VERSION 里面的clusterID
每次格式化,name下面的VERSION的clusterID会产生一个新的ID,要去修改各个节点的VERSION的clusterID 

……/dfs/data/current


storageID=DS-1959445666-10.161.138.100-50010-1386493413986
clusterID=CID-64a3a726-29e4-4d80-86a6-035ef33a225b
cTime=0
storageType=DATA_NODE
layoutVersion=-47

……/dfs/name/current/VERSION
#Fri Jan 03 10:37:48 CST 2014
namespaceID=1667984727
clusterID=CID-42c6d540-c3ca-44df-95e8-01a6d87effb5
cTime=0
storageType=NAME_NODE
blockpoolID=BP-220196921-10.161.138.100-1388716668863
layoutVersion=-47
常见错误总结
Web note ad 1