用ROOT启动HDFS报错Attempting to operate on hdfs namenode as root

/ 0评 / 2

做小学期项目,安装Hadoop,为了避免权限问题,全程使用root账户操作。

运行start-all.sh时会报错:

[root@master sbin]# ./start-dfs.sh
Starting namenodes on [master]
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 [slave1]
ERROR: Attempting to operate on hdfs secondarynamenode as root
ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.

解决方法是在start-dfs.sh和stop-dfs.sh两个文件开头添加:

HDFS_DATANODE_USER=root
HADOOP_SECURE_DN_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root

在较新版本的Hadoop,第二行内容需要改成:

HDFS_SECURE_DN_USER=hdfs

同理还需要在start-yarn.sh和stop-yarn.sh的开头添加:

YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root

之后运行start-all.sh就没有这个报错了

发表评论

电子邮件地址不会被公开。 必填项已用*标注