当前位置:   article > 正文

hadoop-3.1.3启动HDFS时报错ERROR Attempting to operate on hdfs namenode as root的解决方法_error: attempting to operate on hdfs namenode as r

error: attempting to operate on hdfs namenode as root error: but there is no

今天在使用hadoop时遇到了下面这个问题,看报错信息是用户问题,于是上网查了下解决方案,找到两种方式,我使用的是方法1,下面将两种方式都列给大家参考。

报错场景:

hadoop-3.1.3启动HDFS时报错,具体错误信息如下:

[root@hadoop10 hadoop-3.1.3]# sbin/start-dfs.sh 
Starting namenodes on [hadoop10]
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 [hadoop12]
ERROR: Attempting to operate on hdfs secondarynamenode as root
ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

解决方法1:

直接在环境变量中添加配置

vim /etc/profile.d/my_env.sh

*my_env.sh是自己添加的文件,不建议直接修改profile.d

添加的配置如下:

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
  • 1
  • 2
  • 3
  • 4
  • 5

修改完成后,需要执行以下命令立即生效

source /etc/profile.d/my_env.sh

解决方法2:

*文件在hadoop安装目录的sbin目录下

在start-dfs.sh,stop-dfs.sh 两个文件顶部添加以下参数

HDFS_DATANODE_USER=root
HADOOP_SECURE_DN_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root
  • 1
  • 2
  • 3
  • 4

在start-yarn.sh,stop-yarn.sh两个文件顶部添加以下参数

YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root
  • 1
  • 2
  • 3

修改完成后,将修改的配置文件copy到其他的节点

配置好相应文件后

重新启动即可

sbin/start-dfs.sh

Starting namenodes on [hadoop10]
上一次登录:四 12月 10 10:15:53 CST 2020从 192.168.157.1pts/0 上
Starting datanodes
上一次登录:四 12月 10 10:53:50 CST 2020pts/0 上
hadoop12: Warning: Permanently added 'hadoop12,192.168.157.12' (ECDSA) to the list of known hosts.
localhost: Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
hadoop11: WARNING: /opt/module/hadoop-3.1.3/logs does not exist. Creating.
hadoop12: WARNING: /opt/module/hadoop-3.1.3/logs does not exist. Creating.
Starting secondary namenodes [hadoop12]
上一次登录:四 12月 10 10:53:53 CST 2020pts/0 上
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/472760
推荐阅读
相关标签
  

闽ICP备14008679号