hadoop2.2.0中Namenode的格式及启动

hadoop2.2.0中Namenode的格式及启动

我正在尝试安装单节点配置,我成功下载并解压 tar 并编辑所有配置文件,但在格式化名称节点时遇到问题。

错误如下:

14/07/14 02:56:40 WARN fs.FileUtil: Failed to delete file or dir [/home/renu123/yarn/yarn_data/hdfs/namenode/current/seen_txid]: it still exists.
14/07/14 02:56:40 WARN fs.FileUtil: Failed to delete file or dir [/home/renu123/yarn/yarn_data/hdfs/namenode/current/VERSION]: it still exists.
14/07/14 02:56:40 WARN fs.FileUtil: Failed to delete file or dir [/home/renu123/yarn/yarn_data/hdfs/namenode/current/fsimage_0000000000000000000]: it still exists.
14/07/14 02:56:40 WARN fs.FileUtil: Failed to delete file or dir [/home/renu123/yarn/yarn_data/hdfs/namenode/current/fsimage_0000000000000000000.md5]: it still exists.
14/07/14 02:56:40 FATAL namenode.NameNode: Exception in namenode join
java.io.IOException: Cannot remove current directory: /home/renu123/yarn/yarn_data/hdfs/namenode/current
    at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.clearDirectory(Storage.java:299)
    at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:523)
    at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:544)
    at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:147)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:837)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1213)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1320)
14/07/14 02:56:40 INFO util.ExitUtil: Exiting with status 1
14/07/14 02:56:40 INFO namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at ubuntu/127.0.1.1
************************************************************/

在 google 上搜索后,我通过切换到 root 帐户格式化了 namenode,如下所示:

root@ubuntu:~/yarn/yarn_data/hdfs/namenode# hdfs namenode -format
Re-format filesystem in Storage Directory /home/renu123/yarn/yarn_data/hdfs/namenode ? (Y or N) Y
14/07/14 02:59:30 INFO common.Storage: Storage directory /home/renu123/yarn/yarn_data/hdfs/namenode has been successfully formatted.
14/07/14 02:59:30 INFO namenode.FSImage: Saving image file /home/renu123/yarn/yarn_data/hdfs/namenode/current/fsimage.ckpt_0000000000000000000 using no compression
14/07/14 02:59:30 INFO namenode.FSImage: Image file /home/renu123/yarn/yarn_data/hdfs/namenode/current/fsimage.ckpt_0000000000000000000 of size 196 bytes saved in 0 seconds.
14/07/14 02:59:30 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
14/07/14 02:59:30 INFO util.ExitUtil: Exiting with status 0
14/07/14 02:59:30 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at ubuntu/127.0.1.1
************************************************************/

即使格式化后,我仍然可以看到文件夹中的目录hdfs/namenode,即当前目录

假设 namenode 已被格式化,我继续进行并尝试使用命令启动 namenode start-dfs.sh,但无法启动。

这是从中取出的日志usr/local/hadoop/logs

2014-07-14 02:49:10,478 WARN org.apache.hadoop.hdfs.server.common.Storage: Cannot access storage directory /home/renu123/yarn/yarn_data/hdfs/namenode
2014-07-14 02:49:10,484 INFO org.mortbay.log: Stopped [email protected]:50070
2014-07-14 02:49:10,585 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Stopping NameNode metrics system...
2014-07-14 02:49:10,585 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: NameNode metrics system stopped.
2014-07-14 02:49:10,586 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: NameNode metrics system shutdown complete.
2014-07-14 02:49:10,587 FATAL org.apache.hadoop.hdfs.server.namenode.NameNode: Exception in namenode join
org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /home/renu123/yarn/yarn_data/hdfs/namenode 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:292)
    at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:200)
    at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFSImage(FSNamesystem.java:787)
    at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFromDisk(FSNamesystem.java:568)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.loadNamesystem(NameNode.java:443)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:491)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:684)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:669)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1254)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1320)
2014-07-14 02:49:10,590 INFO org.apache.hadoop.util.ExitUtil: Exiting with status 1
2014-07-14 02:49:10,602 INFO org.apache.hadoop.hdfs.server.namenode.NameNode: SHUTDOWN_MSG: 

帮我找到这个问题的解决方案。

我的配置文件是

核心站点.xml

<configuration>
<property>
   <name>fs.default.name</name>

   <value>hdfs://localhost:9000</value>
</property>
</configuration>

yarn-ste.xml

<configuration>
<!-- Site specific YARN configuration properties -->
<property>
   <name>yarn.nodemanager.aux-services</name>

   <value>mapreduce_shuffle</value>
</property>
<property>
   <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>

   <value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>

mapred-站点.xml

<configuration>
<property>
   <name>mapreduce.framework.name</name>

   <value>yarn</value>
</property>
</configuration>

hdfs-site.xml

<configuration>
<property>
   <name>dfs.replication</name>

   <value>1</value>
 </property>
 <property>
   <name>dfs.namenode.name.dir</name>

   <value>file:/home/renu123/yarn/yarn_data/hdfs/namenode</value>
 </property>
 <property>
   <name>dfs.datanode.data.dir</name>

   <value>file:/home/renu123/yarn/yarn_data/hdfs/datanode</value>
 </property>
</configuration>

答案1

如果您已按照链接中给出的安装步骤进行操作(@Vikas Hardia - 链接有效,请忽略最后附加的' - 可能是拼写错误:) -https://www.digitalocean.com/community/tutorials/how-to-install-hadoop-on-ubuntu-13-10

那么下面的内容应该适合您。

解决方案

sudo chown -R hduser:hadoop /usr/local/hadoop
sudo chown -R hduser:hadoop /usr/local/hadoop_store

这对我有用,如果有任何问题,只需确保您已更改.bashrc文件即可hadoop 用户适当地。

答案2

由于您使用的文件关键字,可能存在问题

<configuration>
<property>
   <name>dfs.replication</name>

   <value>1</value>
 </property>
 <property>
   <name>dfs.namenode.name.dir</name>

   **<value>file:/home/renu123/yarn/yarn_data/hdfs/namenode</value>**
 </property>
 <property>
   <name>dfs.datanode.data.dir</name>

   **<value>file:/home/renu123/yarn/yarn_data/hdfs/datanode</value>**
 </property>
</configuration>

您可能需要删除它“文件:”并指定如下

/home/renu123/yarn/yarn_data/hdfs/namenode

/home/renu123/yarn/yarn_data/hdfs/datanode

答案3

@Renukeshwar,我遇到了同样的问题。如果你查看错误日志中的这些行,

java.io.IOException:Cannot remove directory:/home/renu123/yarn/yarn_data/hdfs/namenode/current
java.io.IOException: Cannot create directory: /home/renu123/yarn/yarn_data/hdfs/namenode/current

当当前用户没有该文件夹的读写权限时,就会发生这种情况。

解决方案

更改所有 .xml 文件中的所有配置后,在终端中输入此内容。这将授予hduser组用户hadoop对该文件夹的访问权限。

sudo chown -R hduser:hadoop /usr/local/hadoop

注意:要检查用户属于哪个组,请键入groups your-username-here

编辑:您可能必须删除 tmp 目录。

sudo rm -R /path-to-your-common-storage

答案4

使用以下方式格式化名称节点

hadoop namenode -format

进一步阅读:https://wiki.apache.org/hadoop/GettingStartedWithHadoop#Formatting_the_Namenode

相关内容