Hadoop:通过Ubuntu 12.04中的NameNode格式化HDFS文件系统

时间:2012-06-28 21:21:42

标签: python database linux ubuntu hadoop

我正在关注本教程http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-single-node-cluster/

注意:是的我知道我已经将hadoop安装到/ usr / local / hadoop / hadoop /但教程没有

当我跑步时:

hduser@ubuntu:~$ /usr/local/hadoop/hadoop/bin/hadoop namenode -format

我得到了

Warning: $HADOOP_HOME is deprecated.

/usr/local/hadoop/hadoop/bin/hadoop: line 320: /usr/lib/jvm/java-6-sun/bin/java: No such  file or directory
/usr/local/hadoop/hadoop/bin/hadoop: line 390: /usr/lib/jvm/java-6-sun/bin/java: No such file or directory

而不是

hduser@ubuntu:/usr/local/hadoop$ hadoop/bin/hadoop namenode -format
10/05/08 16:59:56 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   host = ubuntu/127.0.1.1
STARTUP_MSG:   args = [-format]
STARTUP_MSG:   version = 0.20.2
STARTUP_MSG:   build = https://svn.apache.org/repos/asf/hadoop/common/branches    /branch-0.20 -r 911707; compiled by 'chrisdo' on Fri Feb 19 08:07:34 UTC 2010
************************************************************/
10/05/08 16:59:56 INFO namenode.FSNamesystem: fsOwner=hduser,hadoop
10/05/08 16:59:56 INFO namenode.FSNamesystem: supergroup=supergroup
10/05/08 16:59:56 INFO namenode.FSNamesystem: isPermissionEnabled=true
10/05/08 16:59:56 INFO common.Storage: Image file of size 96 saved in 0 seconds.
10/05/08 16:59:57 INFO common.Storage: Storage directory .../hadoop-hduser/dfs/name has    been successfully formatted.
10/05/08 16:59:57 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at ubuntu/127.0.1.1
************************************************************/
/ usr / local / hadoop / hadoop / bin / hadoop第320行的代码中的

是:

JAVA_PLATFORM=`CLASSPATH=${CLASSPATH} ${JAVA} -Xmx32m ${HADOOP_JAVA_PLATFORM_OPTS}           
org.apache.hadoop.util.PlatformName | sed -e "s/ /_/g"`

和第390行是:

    exec "$JAVA" -Dproc_$COMMAND $JAVA_HEAP_MAX $HADOOP_OPTS -classpath "$CLASSPATH" $CLASS "$@"

知道如何解决这个问题吗?

2 个答案:

答案 0 :(得分:2)

我有以下文件:/usr/lib/hadoop-0.20/bin/hadoop-config.sh(Cloudera安装)

在这里,我可以看到它在以下地方搜索java:

# attempt to find java
if [ -z "$JAVA_HOME" ]; then
  for candidate in \
    /usr/lib/jvm/java-6-sun \
    /usr/lib/jvm/java-1.6.0-sun-1.6.0.*/jre/ \
    /usr/lib/jvm/java-1.6.0-sun-1.6.0.* \
    /usr/lib/j2sdk1.6-sun \
    /usr/java/jdk1.6* \
    /usr/java/jre1.6* \
    /Library/Java/Home \
    /usr/java/default \
    /usr/lib/jvm/default-java ; do
    if [ -e $candidate/bin/java ]; then
      export JAVA_HOME=$candidate
      break
    fi
  done

您的JAVA_HOME设置正确吗?你可以手动设置它然后再尝试再次运行它。

[编辑:根据评论]

  1. 检查是否设置了JAVA_HOME:echo $JAVA_HOME
  2. 找出您的jvm所在的位置,通常位于:/usr/lib/jvm/java-6-sun/
  3. 然后设置它。编辑bashrc和bash_profile:vi ~/.bashrcvi ~/.bash_profile
  4. 添加以下内容:export JAVA_HOME=/usr/lib/jvm/java-6-sun/
  5. 请注意,路径应该基于您找到jvm的位置。

答案 1 :(得分:1)

JAVA_HOME重置为包含java的目录,方法是将此行添加到文件hadoop中的hadoop/bin(在上面的给定路径中):

export JAVA_HOME=/home/hduser/jdk1.7.0_07