当我动态添加一个hadoop从节点的之后,出现了一个问题:
[root@hadoop current]# hadoop-daemon.sh start datanode
starting datanode, logging to /usr/local/hadoop1.1/libexec/../logs/hadoop-root-datanode-hadoop.out
[root@hadoop ~]# jps
jps命令发现没有datanode启动,所以去它提示的路径下查看了hadoop-root-datanode-hadoop.out文件,可以是空白的。
后来在该路径下发现了/usr/local/hadoop1.1/logs/hadoop-root-datanode-hadoop.log文件
查看日志文件
[root@hadoop current]# vim /usr/local/hadoop1.1/logs/hadoop-root-datanode-hadoop.log
STARTUP_MSG: version = 1.1.2
STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.1 -r 1440782; compiled by ‘hortonfo‘ on Thu Jan 31 02:03:24 UTC 2013
************************************************************/
2014-10-31 19:24:28,543 INFO org.apache.hadoop.metrics2.impl.MetricsConfig: loaded properties from hadoop-metrics2.properties
2014-10-31 19:24:28,565 INFO org.apache.hadoop.metrics2.impl.MetricsSourceAdapter: MBean for source MetricsSystem,sub=Stats registered.
2014-10-31 19:24:28,566 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Scheduled snapshot period at 10 second(s).
2014-10-31 19:24:28,566 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: DataNode metrics system started
2014-10-31 19:24:28,728 INFO org.apache.hadoop.metrics2.impl.MetricsSourceAdapter: MBean for source ugi registered.
2014-10-31 19:24:29,221 ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: Incompatible namespaceIDs in /usr/local/hadoop/tmp/dfs/data: namenode namespaceID = 942590743;
datanode namespaceID = 463031076
at org.apache.hadoop.hdfs.server.datanode.DataStorage.doTransition(DataStorage.java:232)
at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:147)
at org.apache.hadoop.hdfs.server.datanode.DataNode.startDataNode(DataNode.java:399)
at org.apache.hadoop.hdfs.server.datanode.DataNode.<init>(DataNode.java:309)
at org.apache.hadoop.hdfs.server.datanode.DataNode.makeInstance(DataNode.java:1651)
at org.apache.hadoop.hdfs.server.datanode.DataNode.instantiateDataNode(DataNode.java:1590)
at org.apache.hadoop.hdfs.server.datanode.DataNode.createDataNode(DataNode.java:1608)
at org.apache.hadoop.hdfs.server.datanode.DataNode.secureMain(DataNode.java:1734)
at org.apache.hadoop.hdfs.server.datanode.DataNode.main(DataNode.java:1751)
2014-10-31 19:24:29,229 INFO org.apache.hadoop.hdfs.server.datanode.DataNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down DataNode at hadoop/192.168.0.100
************************************************************/
读日志文件:
先看到ERROT信息中Incompatible这个单词,意思是“不相容的”。所以我们可以看出是datanode的namespaceID出错了。
所以最后shutDown了。
解决思路:
(1)先去hadoop路径下的配置文件hdfs-site.xml,看看:
[root@hadoop current]# vim /usr/local/hadoop1.1/conf/hdfs-site.xml
.....................................................................................................................................
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.permissions</name>
<value>false</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>${hadoop.tmp.dir}/dfs/name</value>
<description>this is a comma-delimited list of directories
then the name table is replicated in all of the directories,
for redunancy.
</description>
</property>
</configuration>
.....................................................................................................................................
里面并没有有关datanode的配置信息,如果你有类似于下面的内容:
<property>
<name>dfs.data.dir</name>
<value>/data/hdfs/data</value>
</property>
说明你的datanode配置文件不再默认路径,而是你自己设置过的路径下。
(2)进入datanode的 dfs.data.dir 的 current目录,修改里面的文件VERSION
由于我是默认的,所以路径是/usr/local/hadoop/tmp/dfs/data/current/VERSION。
这个版本不同,可能路径也不同,最好自己去找找。
[root@hadoop current]# vim /usr/local/hadoop/tmp/dfs/data/current/VERSION
.....................................................................................................................................
#Thu Oct 30 04:52:01 PDT 2014
namespaceID=463031076
storageID=DS-1787154912-192.168.0.100-50010-1413940826285
cTime=0
storageType=DATA_NODE
layoutVersion=-32
.....................................................................................................................................
看里面的namespaceID=463031076,可以发现,跟hadoop-root-datanode-hadoop.log中的datanode namespaceID = 463031076的一样,这说明他是读取这个文件的,所以我们没有找错。
(3)修改这个版本信息文件VERSION
ID与hadoop-root-datanode-hadoop.log中 namenode namespaceID = 942590743一致
ps:我想大家应该可以想到namenode namespaceID是从哪里来的:
[root@hadoop current]# vim /usr/local/hadoop/tmp/dfs/name/current/VERSION
.....................................................................................................................................
#Fri Oct 31 19:23:44 PDT 2014
namespaceID=942590743
cTime=0
storageType=NAME_NODE
layoutVersion=-32
.....................................................................................................................................
这里的ID是不是与hadoop-root-datanode-hadoop.log中 namenode namespaceID = 942590743一致?
(4)修改完以后,重新运行datanode
[root@hadoop current]# hadoop-daemon.sh start datanode
[root@hadoop current]# jps
8581 DataNode
看到DataNode,说明已经跑起来了。