具体为:
[email protected]:~/hadoop-1.2.1$ start-all.sh
starting namenode, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-namenode-dy-virtual-machine.out
localhost: starting datanode, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-datanode-dy-virtual-machine.out
localhost: Error: JAVA_HOME is not set.
localhost: starting secondarynamenode, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-secondarynamenode-dy-virtual-machine.out
localhost: Error: JAVA_HOME is not set.
starting jobtracker, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-jobtracker-dy-virtual-machine.out
localhost: starting tasktracker, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-tasktracker-dy-virtual-machine.out
localhost: Error: JAVA_HOME is not set.
解决方法:
在/hadoop-1.2.1/conf/文件夹里有个hadoop-env.sh的文件,它的作用是配置与hadoop运行环境相关的变量
找到:
# The java implementation to use. Required.
# export JAVA_HOME=/usr/lib/jvm/java-6-sun
将#号去掉,变为:
改成你本机的jdk路径,执行完退出
:wq
若你不清楚自己的jdk路径,你可以先执行 echo $JAVA_HOME 进行查看