默认情况下,Hadoop 将 hadoop.tmp.dir 设置为您的 /tmp 文件夹。这是一个问题,因为 /tmp 会在您重新启动时被 Linux 清除,从而导致 JobTracker 出现这个可爱的错误:
2012-10-05 07:41:13,618 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 0 time(s).
...
2012-10-05 07:41:22,636 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 9 time(s).
2012-10-05 07:41:22,643 INFO org.apache.hadoop.mapred.JobTracker: problem cleaning system directory: null
java.net.ConnectException: Call to localhost/127.0.0.1:8020 failed on connection exception: java.net.ConnectException: Connection refused
at org.apache.hadoop.ipc.Client.wrapException(Client.java:767)
我发现解决此问题的唯一方法是重新格式化您的名称节点,它会重建 /tmp/hadoop-root 文件夹,当您重新启动时,它当然会再次被清除。
所以我继续创建了一个名为 /hadoop_temp 的文件夹,并为所有用户提供了对它的读/写访问权限。然后我在我的 core-site.xml 中设置这个属性:
<property>
<name>hadoop.tmp.dir</name>
<value>file:///hadoop_temp</value>
</property>
当我重新格式化我的 namenode 时,Hadoop 似乎很高兴,给了我这样的信息:
12/10/05 07:58:54 INFO common.Storage: Storage directory file:/hadoop_temp/dfs/name has been successfully formatted.
但是,当我查看 /hadoop_temp 时,我注意到该文件夹是空的。然后当我重新启动 Hadoop 并检查我的 JobTracker 日志时,我看到了:
2012-10-05 08:02:41,988 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 0 time(s).
...
2012-10-05 08:02:51,010 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: localhost/127.0.0.1:8020. Already tried 9 time(s).
2012-10-05 08:02:51,011 INFO org.apache.hadoop.mapred.JobTracker: problem cleaning system directory: null
java.net.ConnectException: Call to localhost/127.0.0.1:8020 failed on connection exception: java.net.ConnectException: Connection refused
当我检查我的namenode日志时,我看到了:
2012-10-05 08:00:31,206 INFO org.apache.hadoop.hdfs.server.common.Storage: Storage directory /opt/hadoop/hadoop-0.20.2/file:/hadoop_temp/dfs/name does not exist.
2012-10-05 08:00:31,212 ERROR org.apache.hadoop.hdfs.server.namenode.FSNamesystem: FSNamesystem initialization failed.
org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /opt/hadoop/hadoop-0.20.2/file:/hadoop_temp/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.
所以,显然我没有配置正确的东西。即使我在 core-site.xml 中将 hadoop.tmp.dir 设置为 /hadoop_temp,Hadoop 仍然希望在 /tmp 文件夹中看到它的文件。我做错了什么?hadoop.tmp.dir 接受的“正确”值是多少?
奖励问题:我应该为 hbase.tmp.dir 使用什么?
系统信息 :
Ubuntu 12.04、Apache Hadoop .20.2、Apache HBase .92.1
谢谢参观!