启动hadoop发现slave中jps没有datanode进程

现象:

在slave1中jps发现没有datanode进程,查看日志hadoop-root-datanode-slave1.log发现:

2019-04-14 11:45:25,093 INFO org.apache.hadoop.hdfs.server.common.Storage: Lock on /usr/hadoop/hadoop-2.7.3/hdfs/data/in_use.lock acquired by nodena
me 4517@slave1
2019-04-14 11:45:25,095 WARN org.apache.hadoop.hdfs.server.common.Storage: Failed to add storage directory [DISK]file:/usr/hadoop/hadoop-2.7.3/hdfs/
data/
java.io.IOException: Incompatible clusterIDs in /usr/hadoop/hadoop-2.7.3/hdfs/data: namenode clusterID = CID-9df18536-da8b-4e32-8ced-e779a18cfc16; d
atanode clusterID = CID-9529ac9d-6a5f-4181-a995-d09c9232125e
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.doTransition(DataStorage.java:775)
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.loadStorageDirectory(DataStorage.java:300)
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.loadDataStorage(DataStorage.java:416)
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.addStorageLocations(DataStorage.java:395)
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:573)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1362)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1327)
        at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:317)
        at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:223)
        at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:802)
        at java.lang.Thread.run(Thread.java:748)
2019-04-14 11:45:25,097 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed for Block pool  (Datanode Uuid unassigned) service to master/192.168.11.4:9000. Exiting.
java.io.IOException: All specified directories are failed to load.
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:574)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1362)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1327)
        at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:317)
        at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:223)
        at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:802)
        at java.lang.Thread.run(Thread.java:748)
2019-04-14 11:45:25,098 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Ending block pool service for: Block pool  (Datanode Uuid unassigned) service to master/192.168.11.4:9000
2019-04-14 11:45:25,206 INFO org.apache.hadoop.hdfs.server.datanode.DataNode: Removed Block pool  (Datanode Uuid unassigned)
2019-04-14 11:45:27,207 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Exiting Datanode
2019-04-14 11:45:27,208 INFO org.apache.hadoop.util.ExitUtil: Exiting with status 0
2019-04-14 11:45:27,210 INFO org.apache.hadoop.hdfs.server.datanode.DataNode: SHUTDOWN_MSG:
/************************************************************

原因:

多次格式化namenode,datanode中保存的current/VERSION文件中的clustreID的值是上一次格式化保存的clusterID,使得datanode和namenode之间的ID不一致

解决方案:

方案①如果hdfs文件夹中没有重要的数据,那么删除hdfs文件夹,再重新格式化
方案②hdfs中有重要数据,在master的hdfs/name目录下找到一个current/VERSION文件,记录clusterID并复制。然后在slave的hdfs/data目录下找到一个current/VERSION文件,将其中clustreID的值替换成刚刚复制的clusterID的值

你可能感兴趣的:(大数据,hadoop)