且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:找不到或加载主类org.apache.hadoop.hdfs.server.namenode.NameNode尝试了所有解决方案,但错误仍然存​​在

更新时间:2022-04-02 06:45:47

造成此问题的一个原因可能是用户定义的 HDFS_DIR 环境变量.这是由脚本完成的,例如 libexec/hadoop-functions.sh 中的以下行:

One cause behind this problem might be a user-defined HDFS_DIR environment variable. This is picked up by scripts such as the following lines in libexec/hadoop-functions.sh:

HDFS_DIR=${HDFS_DIR:-"share/hadoop/hdfs"}
...
if [[ -z "${HADOOP_HDFS_HOME}" ]] &&
   [[ -d "${HADOOP_HOME}/${HDFS_DIR}" ]]; then
  export HADOOP_HDFS_HOME="${HADOOP_HOME}"
fi

解决方案是避免定义环境变量 HDFS_DIR .

The solution is to avoid defining an environment variable HDFS_DIR.

问题注释中的建议是正确的–使用 hadoop classpath 命令来识别 hadoop-hdfs-*.jar 文件是否存在于类路径中.在我的情况下,他们不见了.

The recommendations in the comments of question are correct – use the hadoop classpath command to identify whether hadoop-hdfs-*.jar files are present in the classpath or not. They were missing in my case.