测试环境,由于测试需求,重新format namenode后,导致datanode无法正常启动。
1. 查看datanode日志,可以发现错误“Initialization failed for Block pool <registering> (Datanode Uuid unassigned)”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
2018-01-27 20:09:49,052 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed
for
Block pool <registering> (Datanode Uuid unassigned) service to c6704/192.168.67.104:9000. Exiting.
java.io.IOException: All specified directories are failed to load.
at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:478)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1361)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1326)
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:801)
at java.lang.Thread.run(Thread.java:745)
2018-01-27 20:09:49,056 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed
for
Block pool <registering> (Datanode Uuid unassigned) service to c6705/192.168.67.105:9000. Exiting.
java.io.IOException: All specified directories are failed to load.
at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:478)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1361)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1326)
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:801)
at java.lang.Thread.run(Thread.java:745)
2018-01-27 20:09:49,069 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Ending block pool service
for
: Block pool <registering> (Datanode Uuid unassigned) service to c6705/192.168.67.105:9000
2018-01-27 20:09:49,070 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Ending block pool service
for
: Block pool <registering> (Datanode Uuid unassigned) service to c6704/192.168.67.104:9000
2018-01-27 20:09:49,192 INFO org.apache.hadoop.hdfs.server.datanode.DataNode: Removed Block pool <registering> (Datanode Uuid unassigned)
2018-01-27 20:09:51,193 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Exiting Datanode
2018-01-27 20:09:51,204 INFO org.apache.hadoop.util.ExitUtil: Exiting with status 0
2018-01-27 20:09:51,208 INFO org.apache.hadoop.hdfs.server.datanode.DataNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down DataNode at c6706.python279.org/192.168.67.106
************************************************************/
|
2. 经过百度,根据日志描述,原因是datanode的clusterID 和 namenode的clusterID 不匹配。
打开hdfs-site.xml中关于datanode和namenode对应的目录,分别打开其中的current/VERSION文件,进行对比。
3. namenode的VERSION内容如下:
1
2
3
4
5
6
7
8
|
[hdfs@c6704 $ cat /data/hadoop/hdfs/name/current/VERSION
#Sat Jan 27 00:46:30 UTC 2018
namespaceID=1148548909
clusterID=CID-aedb2e82-77f2-4056-b676-dca88083215d
cTime=0
storageType=NAME_NODE
blockpoolID=BP-1099214307-192.168.67.104-1517013990445
layoutVersion=-63
|
4. datanode的VERSION文件内容如下:
1
2
3
4
5
6
7
8
9
|
[hdfs@c6706 ~]$ cat /data/hadoop/hdfs/data/current/VERSION
#Sat Jan 27 00:20:21 UTC 2018
storageID=DS-8f0fdd04-e967-43cd-bd41-93b826b675b8
clusterID=CID-b27ecfd8-64ba-4e43-bd82-4ef6f2edd60c
cTime=0
datanodeUuid=264b1b43-82c0-411c-859f-32761edc7465
storageType=DATA_NODE
layoutVersion=-56
5. namenode和datano
|
de的版本是不同的,决定备份datanode,并清空VERSION,然后启动datanode,问题依旧。检查VERSION,内容是空的。
1
2
3
|
[hdfs@c6706 current]$ cp VERSION VERSION.bk
[hdfs@c6706 current]$ echo > VERSION
[hdfs@c6706 current]$ cat VERSION
|
6. 删除VERSION,再次启动datanode,VERSION内容已经同步。
1
2
3
4
5
6
7
8
|
$ cat VERSION
#Sun Jan 28 01:29:46 UTC 2018
storageID=DS-1c1f5e05-df2c-40de-b39b-d6d54e3c4894
clusterID=CID-aedb2e82-77f2-4056-b676-dca88083215d ##<<<<<同步了
cTime=0
datanodeUuid=948d5780-053e-4752-9476-fb1d1debda72
storageType=DATA_NODE
layoutVersion=-56
|
7. 通过页面也可以查询到datanode了。
8. 问题原因
执行hdfs namenode -format后,current目录会删除并重新生成,其中VERSION文件中的clusterID也会随之变化,而datanode的VERSION文件中的clusterID保持不变,造成两个clusterID不一致。
所以为了避免这种情况,可以再执行的namenode格式化之后,删除datanode的current文件夹,或者修改datanode的VERSION文件中出clusterID与namenode的VERSION文件中的clusterID一样,然后重新启动datanode。