Hadoop啟動出錯:*is in an inconsistent state: storage directory does not exist or is not accessible


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格式化時會自動創建,如果預先創建反而會有問題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM