Some problems in installing Hadoop.ERROR: Attempting to operate on hdfs namenode as root ERROR:

Some problems in installing Hadoop.ERROR: Attempting to operate on hdfs namenode as root ERROR:

我是Hadoop的新手。我在它的配置中遇到了一些问题。在此之前,我完成了JAVA、SSH、core-site.xml、hdfs-site.xml和hadoop-env.sh的配置。请告诉我如何解决它。非常感谢。

root@host1-virtual-machine:/home/host1/usr/hadoop-3.2.1# sbin/start-all.sh
Starting namenodes on [localhost]
ERROR: Attempting to operate on hdfs namenode as root
ERROR: but there is no HDFS_NAMENODE_USER defined. Aborting operation.
Starting datanodes
ERROR: Attempting to operate on hdfs datanode as root
ERROR: but there is no HDFS_DATANODE_USER defined. Aborting operation.
Starting secondary namenodes [host1-virtual-machine]
ERROR: Attempting to operate on hdfs secondarynamenode as root
ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.
2020-02-12 13:19:37,322 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting resourcemanager
ERROR: Attempting to operate on yarn resourcemanager as root
ERROR: but there is no YARN_RESOURCEMANAGER_USER defined. Aborting operation.
Starting nodemanagers
ERROR: Attempting to operate on yarn nodemanager as root
ERROR: but there is no YARN_NODEMANAGER_USER defined. Aborting operation.

在我将 5 行添加到 hadoop-env.sh 后,它会发出以下警告:

Starting namenodes on [localhost]
localhost: root@localhost: Permission denied (publickey,password).
Starting datanodes
localhost: root@localhost: Permission denied (publickey,password).
Starting secondary namenodes [host1-virtual-machine]
host1-virtual-machine: root@host1-virtual-machine: Permission denied (publickey,password).
2020-02-12 20:26:27,702 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting resourcemanager
Starting nodemanagers
localhost: root@localhost: Permission denied (publickey,password).

此问题的原因是在安装和启动服务时使用了不同的用户。 您可以在 hadoop-env.sh 中将用户定义为 root,如下所示:

export HDFS_NAMENODE_USER=root
export HDFS_DATANODE_USER=root
export HDFS_SECONDARYNAMENODE_USER=root
export YARN_RESOURCEMANAGER_USER=root
export YARN_NODEMANAGER_USER=root

希望对您有所帮助