[root@node1 hadoop]# ./sbin/start-all.sh
Starting namenodes on [node1]
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 [node1]
ERROR: Attempting to operate on hdfs secondarynamenode as root
ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.
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.
ERROR: Attempting to operate on yarn proxyserver as root
ERROR: but there is no YARN_PROXYSERVER_USER defined. Aborting operation.
原因是Hadoop不允许以root用户身份启动Hadoop服务,因为Hadoop需要特定的环境变量来指定运行服务的用户。
我是这样解决的:
1、在终端输入以下命令来编辑 /etc/profile
文件:
sudo vi /etc/profile
2、按 i
键进入插入模式,在文件的末尾或您希望添加内容的位置,粘贴以下内容:
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
3、完成编辑后,按 Esc
键退出插入模式。输入 :wq
保存更改并退出 vi
编辑器。
4、终端运行以下命令,使修改生效
source /etc/profile
5、接下来在终端输入以下命令,就会解决部分问题
./sbin/start-all.sh
6、发现还有问题
ERROR: Attempting to operate on yarn proxyserver as root
ERROR: but there is no YARN_PROXYSERVER_USER defined. Aborting operation.
问题在于:Hadoop 启动脚本尝试以 root 用户身份运行 yarn proxyserver,但是没有定义 YARN_PROXYSERVER_USER
环境变量
所有你需要在 Hadoop 的环境配置文件中设置 YARN_PROXYSERVER_USER
。
7、终端输入命令,打开 hadoop-env.sh
文件:
sudo vi /export/server/hadoop/etc/hadoop/hadoop-env.sh(这里编辑方式同上)
8、我直接在文件末尾添加命令export YARN_PROXYSERVER_USER=root
解决了第六的问题,然后我这还出现了一个问题,此外,这个东西是正确的,但是我用错账号了,