启动Hadoop报错【Error: JAVA_HOME is not set and could not be found.】

After spending an afternoon installing Hadoop from scratch, I was excited to start it!
Error: JAVA_HOME is not set and could not be found.
He told me that JAVA_HOME was not found?
Insert image description here
I obviously installed java, why can't I find it?
I checked java -version and found that there is no problem.
Solution:
Later I found that the java path on Hadoop was not configured, that is, the Hadoop environment variables were not configured.
Enter the hadhoop folder.

cd hadoop/etc/hadoop/
vim hadoop-env.sh
G跳到文末

addition

export JAVA_HOME=/usr/java/jdk1.8.0_181-amd64  每个人版本号不同而且这个地址要到bin目录的上一层才可以!
export HADOOP_CONF_DIR=/usr/local/hadoop/etc/hadoop
Esc :wq 保存退出
source hadoop-env.sh 重新执行sh文件 就成功了

Insert image description here

Insert image description here

Finally, fill in a pit: It is recommended not to modify the jdk name.
Insert image description here
After I modified it, the name changed. After looking at the detailed information, wls said that the soft link had changed, and then the entire folder became unusable. Insert image description here
In fact, there is no impact if you directly delete or ignore these two folders (no impact here means that you can start Hadoop) , but they are really ugly and I have a little obsessive-compulsive disorder . I directly forcefully deleted the java folder and wanted to reinstall it. java environment, the result is the following article .

Guess you like

Origin blog.csdn.net/weixin_51461002/article/details/129915294