1. 基本信息html
hadoop 版本 hadoop-0.20.205.0.tar.gzjava
操做系統 ubuntunode
2. 問題linux
在使用Hadoop開發初期的時候遇到一個問題。 每次重啓系統後發現不能正常運行hadoop。必須執行 bin/hadoop namenode -format 進行格式化才能成功運行hadoop,可是也就意味着之前記錄的name等數據丟失。web
查詢日誌發現錯誤: apache
- 21:08:48,103 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Registered FSNamesystemStateMBean and NameNodeMXBean
- 21:08:48,125 INFO org.apache.hadoop.hdfs.server.namenode.NameNode: Caching file names occuring more than 10 times
- 21:08:48,129 INFO org.apache.hadoop.hdfs.server.common.Storage: Storage directory /tmp/hadoop-sylar/dfs/name does not exist.
- 21:08:48,130 ERROR org.apache.hadoop.hdfs.server.namenode.FSNamesystem: FSNamesystem initialization failed.
- 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.
- at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:288)
- at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:97)
- at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:384)
- at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:358)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:276)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:497)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1268)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1277)
3.緣由ubuntu
後查詢文檔時發現, 在linux下hadoop等的各類數據保存在/tmp目錄下。 當重啓系統後/tmp目錄中的數據信息被清除,致使hadoop啓動失敗。 當bin/hadoop namenode -format 格式化後,恢復了默認設置,便可正常啓動。ide
4. 解決oop
須要在配置文件core-site.xml中指定臨時目錄的存儲位置, 現貼出修改後的配置this
- <?xml version="1.0"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
- <!-- Put site-specific property overrides in this file. -->
-
- <configuration>
-
- <property>
- <name>fs.default.name</name>
- <value>hdfs://127.0.0.1:9000</value>
- </property>
-
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/home/hadoopdata/tmp</value>
- <description>A base for other temporary directories.</description>
- </property>
-
- <property>
- <name>dfs.name.dir</name>
- <value>/home/hadoopdata/filesystem/name</value>
- <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>
- </property>
-
- <property>
- <name>dfs.data.dir</name>
- <value>/home/hadoopdata/filesystem/data</value>
- <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>
- </property>
-
- <property>
- <name>dfs.replication</name>
- <value>1</value>
- <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>
- </property>
-
- </configuration>
dfs.name.dir是NameNode持久存儲名字空間及事務日誌的本地文件系統路徑。當這個值是一個逗號分割的目錄列表時,nametable數據將會被複制到全部目錄中作冗餘備份。
dfs.data.dir是DataNode存放塊數據的本地文件系統路徑,逗號分割的列表。當這個值是逗號分割的目錄列表時,數據將被存儲在全部目錄下,一般分佈在不一樣設備上。
dfs.replication是數據須要備份的數量,默認是3,若是此數大於集羣的機器數會出錯。
注意:此處的name一、name二、data一、data2目錄不能預先建立,hadoop格式化時會自動建立,若是預先建立反而會有問題。
1. 基本信息
hadoop 版本 hadoop-0.20.205.0.tar.gz
操做系統 ubuntu
2. 問題
在使用Hadoop開發初期的時候遇到一個問題。 每次重啓系統後發現不能正常運行hadoop。必須執行 bin/hadoop namenode -format 進行格式化才能成功運行hadoop,可是也就意味着之前記錄的name等數據丟失。
查詢日誌發現錯誤:
- 21:08:48,103 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Registered FSNamesystemStateMBean and NameNodeMXBean
- 21:08:48,125 INFO org.apache.hadoop.hdfs.server.namenode.NameNode: Caching file names occuring more than 10 times
- 21:08:48,129 INFO org.apache.hadoop.hdfs.server.common.Storage: Storage directory /tmp/hadoop-sylar/dfs/name does not exist.
- 21:08:48,130 ERROR org.apache.hadoop.hdfs.server.namenode.FSNamesystem: FSNamesystem initialization failed.
- 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.
- at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:288)
- at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:97)
- at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:384)
- at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:358)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:276)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:497)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1268)
- 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中指定臨時目錄的存儲位置, 現貼出修改後的配置
- <?xml version="1.0"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
- <!-- Put site-specific property overrides in this file. -->
-
- <configuration>
-
- <property>
- <name>fs.default.name</name>
- <value>hdfs://127.0.0.1:9000</value>
- </property>
-
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/home/hadoopdata/tmp</value>
- <description>A base for other temporary directories.</description>
- </property>
-
- <property>
- <name>dfs.name.dir</name>
- <value>/home/hadoopdata/filesystem/name</value>
- <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>
- </property>
-
- <property>
- <name>dfs.data.dir</name>
- <value>/home/hadoopdata/filesystem/data</value>
- <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>
- </property>
-
- <property>
- <name>dfs.replication</name>
- <value>1</value>
- <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>
- </property>
-
- </configuration>
dfs.name.dir是NameNode持久存儲名字空間及事務日誌的本地文件系統路徑。當這個值是一個逗號分割的目錄列表時,nametable數據將會被複制到全部目錄中作冗餘備份。
dfs.data.dir是DataNode存放塊數據的本地文件系統路徑,逗號分割的列表。當這個值是逗號分割的目錄列表時,數據將被存儲在全部目錄下,一般分佈在不一樣設備上。
dfs.replication是數據須要備份的數量,默認是3,若是此數大於集羣的機器數會出錯。
注意:此處的name一、name二、data一、data2目錄不能預先建立,hadoop格式化時會自動建立,若是預先建立反而會有問題。