When Hadoop executes start-yarn.sh, it will report an error of “error: attempting to operate on yarn ResourceManager as root”.
Method 1
sudo vim ~/.bashrc
Add the following parameters at the end:
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
Method 2
Add the following parameters at the top of the start-dfs.sh and stop-dfs.sh files:
HDFS_DATANODE_USER=root HADOOP_SECURE_DN_USER=hdfs HDFS_NAMENODE_USER=root HDFS_SECONDARYNAMENODE_USER=root
Add the following parameters at the top of the start-yarn.sh and stop-yarn.sh files:
YARN_RESOURCEMANAGER_USER=root HADOOP_SECURE_DN_USER=yarn YARN_NODEMANAGER_USER=root
*The above files are in the SBIN directory of the Hadoop root directory.
*The official recommendation is to create a new independent account for yarn to start.