start-all.sh指令碼啟動Hadoop的NameNode、DataNode、ResourceManager和NodeManager失敗

不会JAVA的小袁發表於2024-11-05
今天在做大資料實驗時,在終端,start-all.sh指令碼啟動Hadoop的NameNode、DataNode、ResourceManager和NodeManager失敗,出現下面的錯誤資訊:

[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

解決了第六的問題,然後我這還出現了一個問題,此外,這個東西是正確的,但是我用錯賬號了,

相關文章