Error Reported When hdfs namenode -format Is Run
Symptom
The error message "Error: JAVA_HOME is not set and could not be found" is displayed when hdfs namenode -format is run.
Key Process and Cause Analysis
The JAVA_HOME environment variable is incorrectly set.
Conclusion and Solution
Set the JAVA_HOME variable by referring to Installing the Java Environment.
If JAVA_HOME is correctly set, modify the ./etc/hadoop/hadoop-env.sh file.
- Open the ./etc/hadoop/hadoop-env.sh file.
vi ./etc/hadoop/hadoop-env.sh
- Press i to enter the insert mode and add the following environment variable to the environment variable file:
expect JAVA_HOME=JDK_installation_path
- Press Esc, type :wq!, and press Enter to save the settings and exit.