启动hdfs后(start-dfs.sh), 发现jps中namenode的进程不存在,导致hdfs连接不成功。
查看log,发现其中:
2015-03-11 20:23:00,986 FATAL org.apache.hadoop.hdfs.server.namenode.NameNode: Exception in namenode join
org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /tmp/hadoop-root/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.
at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverStorageDirs(FSImage.java:311)
at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:202)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFSImage(FSNamesystem.java:955)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFromDisk(FSNamesystem.java:700)
at org.apache.hadoop.hdfs.server.namenode.NameNode.loadNamesystem(NameNode.java:529)
at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:585)
at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:751)
at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:735)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1407)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1473)
2015-03-11 20:23:00,988 INFO org.apache.hadoop.util.ExitUtil: Exiting with status 1
2015-03-11 20:23:00,989 INFO org.apache.hadoop.hdfs.server.namenode.NameNode: SHUTDOWN_MSG:
org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /tmp/hadoop-root/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.
at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverStorageDirs(FSImage.java:311)
at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:202)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFSImage(FSNamesystem.java:955)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFromDisk(FSNamesystem.java:700)
at org.apache.hadoop.hdfs.server.namenode.NameNode.loadNamesystem(NameNode.java:529)
at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:585)
at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:751)
at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:735)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1407)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1473)
2015-03-11 20:23:00,988 INFO org.apache.hadoop.util.ExitUtil: Exiting with status 1
2015-03-11 20:23:00,989 INFO org.apache.hadoop.hdfs.server.namenode.NameNode: SHUTDOWN_MSG:
检查后发现hadoop配置文件 etc/hadoop/core-site.xml 中有一处配置 hadoop.tmp.dir, 原先配置在了/tmp/目录下。
由于Ubuntu会自动清理该目录,机器重启后该目录被清空,导致该问题。
解决方法是:
修改该配置文件:
<
property
>
<
name
>hadoop.tmp.dir</
name
>
<
value
>/hdfs/name</
value
>
<
description
>A base for other temporary directories.</
description
>
</
property
>
并且重新fomat hdfs,重新启动hdfs后问题解决:
root@ubuntu:~# jps
11076 NameNode
11304 DataNode
11593 SecondaryNameNode
11722 Jps
11076 NameNode
11304 DataNode
11593 SecondaryNameNode
11722 Jps