在 OS X 上配置 Hadoop 出现错误

configuring Hadoop on OS X got the error

我收到错误:第 144 行:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java:没有那个文件或目录

按照http://www.talendbyexample.com/configuring-hadoop-2.html and http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/SingleCluster.html,

配置后

我输入:

$ hadoop version

得到了

/hadoop/hadoop2/bin/hadoop: line 144: /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java: No such file or directory
/hadoop/hadoop2/bin/hadoop: line 144: exec: /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java: cannot execute: No such file or directory

hadoop 命令使用以下命令:

exec "$JAVA" ..

JAVA 变量由 hadoop_config.sh 设置,由 hadoop 命令获取。其设置为:

JAVA=$JAVA_HOME/bin/java

这意味着您的 JAVA_HOME 不正确。因此,为 JAVA_HOME 分配适当的值并重新运行命令。