现在的位置: 首页 > 综合 > 正文

Hadoop启动出错:*is in an inconsistent state: storage directory does not exist or is not accessible

2013年10月04日 ⁄ 综合 ⁄ 共 3546字 ⁄ 字号 评论关闭

1. 基本信息

hadoop    版本 hadoop-0.20.205.0.tar.gz

操作系统   ubuntu

2. 问题

在使用Hadoop开发初期的时候遇到一个问题。 每次重启系统后发现不能正常运行hadoop。必须执行  bin/hadoop namenode -format  进行格式化才能成功运行hadoop,但是也就意味着以前记录的name等数据丢失。

 查询日志发现错误: 

  1. 21:08:48,103 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Registered FSNamesystemStateMBean and NameNodeMXBean  
  2. 21:08:48,125 INFO org.apache.hadoop.hdfs.server.namenode.NameNode: Caching file names occuring more than 10 times   
  3. 21:08:48,129 INFO org.apache.hadoop.hdfs.server.common.Storage: Storage directory /tmp/hadoop-sylar/dfs/name does not exist.  
  4. 21:08:48,130 ERROR org.apache.hadoop.hdfs.server.namenode.FSNamesystem: FSNamesystem initialization failed.  
  5. org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /tmp/hadoop-sylar/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.  
  6.     at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:288)  
  7.     at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:97)  
  8.     at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:384)  
  9.     at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:358)  
  10.     at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:276)  
  11.     at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:497)  
  12.     at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1268)  
  13.     at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1277)  



3.原因

后查询文档时发现, 在linux下hadoop等的各种数据保存在/tmp目录下。 当重启系统后/tmp目录中的数据信息被清除,导致hadoop启动失败。 当bin/hadoop namenode -format 格式化后,恢复了默认设置,即可正常启动。

4. 解决

 需要在配置文件core-site.xml中指定临时目录的存储位置, 现贴出修改后的配置

  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3.   
  4. <!-- Put site-specific property overrides in this file. -->  
  5.   
  6. <configuration>  
  7.   
  8. <property>  
  9.          <name>fs.default.name</name>  
  10.          <value>hdfs://127.0.0.1:9000</value>  
  11.      </property>  
  12.   
  13. <property>  
  14.     <name>hadoop.tmp.dir</name>  
  15.     <value>/home/hadoopdata/tmp</value>  
  16.     <description>A base for other temporary directories.</description>  
  17. </property>  
  18.    
  19. <property>  
  20.     <name>dfs.name.dir</name>  
  21.     <value>/home/hadoopdata/filesystem/name</value>  
  22.     <description>Determines where on the local filesystem the DFS name node should store the name table. If this is a comma-delimited list of directories then the name table is replicated in all of the directories, for redundancy. </description>  
  23. </property>  
  24.    
  25. <property>  
  26.     <name>dfs.data.dir</name>  
  27.     <value>/home/hadoopdata/filesystem/data</value>  
  28.     <description>Determines where on the local filesystem an DFS data node should store its blocks. If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices. Directories that do not exist are ignored.</description>  
  29. </property>  
  30.    
  31. <property>  
  32.     <name>dfs.replication</name>  
  33.     <value>1</value>  
  34.     <description>Default block replication. The actual number of replications can be specified when the file is created. The default isused if replication is not specified in create time.</description>  
  35. </property>  
  36.   
  37. </configuration>  


dfs.name.dir是NameNode持久存储名字空间及事务日志的本地文件系统路径。当这个值是一个逗号分割的目录列表时,nametable数据将会被复制到所有目录中做冗余备份。

dfs.data.dir是DataNode存放块数据的本地文件系统路径,逗号分割的列表。当这个值是逗号分割的目录列表时,数据将被存储在所有目录下,通常分布在不同设备上。

dfs.replication是数据需要备份的数量,默认是3,如果此数大于集群的机器数会出错。

注意:此处的name1、name2、data1、data2目录不能预先创建,hadoop格式化时会自动创建,如果预先创建反而会有问题。

抱歉!评论已关闭.