以下内容根据 DoNotStop 的博客进行整理。
报错
我是在安装 hadoop-3.1.3.tar.gz 单机版后启动时遇到的报错,内容如下:
[root@tcloud sbin]# ./start-dfs.sh
Starting namenodes on [tcloud]
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 [tcloud]
ERROR: Attempting to operate on hdfs secondarynamenode as root
ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.
解决
在 ${HADOOP_HOME}/sbin路径下
start-dfs.sh,stop-dfs.sh 这两个文件顶部添加以下参数:
HDFS_DATANODE_USER=root
HADOOP_SECURE_DN_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root
start-yarn.sh,stop-yarn.sh 这两个文件顶部添加以下参数:
YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root
启动后报错:
WARNING: HADOOP_SECURE_DN_USER has been replaced by HDFS_DATANODE_SECURE_USER.
Using value of HADOOP_SECURE_DN_USER.
最终修改:
start-dfs.sh,stop-dfs.sh 这两个文件顶部添加以下参数:
HDFS_DATANODE_USER=root
HDFS_DATANODE_SECURE_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root
start-yarn.sh,stop-yarn.sh 这两个文件顶部添加以下参数:
YARN_RESOURCEMANAGER_USER=root
HDFS_DATANODE_SECURE_USER=yarn
YARN_NODEMANAGER_USER=root
说明:
- 集群版的 master和slav e都需要修改start-dfs.sh、stop-dfs.sh、start-yarn.sh、stop-yarn.sh这四个文件。
- 如果Hadoop是其它用户启动,要修改用户名。