Hadoop 重新编译-解决root用户提交任务报错Running as root is not allowed
本文主要解决Hadoop root用户无法提交问题
Running as root is not allowed
Linux架构:arm或者x86都可以
Jdk版本:jdk1.8
cmake版本:3.19
Hadoop版本:3.2.1
Maven版本:3.6.3
Protobuf版本:2.5
查看报错 是因为在源码中做出了限制
/Users/mac/Desktop/客户/源码/hadoop-3.2.1-src/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/
struct passwd* check_user(const char *user) {
// if (strcmp(user, "root") == 0) {
// fprintf(LOGFILE, "Running as root is not allowed\n");
// fflush(LOGFILE);
// return NULL;
// }
开启cgroup和LinuxContainerExecutor后无法用root去提交
修改/opt/hadoop-3.2.1-src01/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.c
改成这个样子
然后退到/opt/hadoop-3.2.1-src01/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager
开始编译
mvn package -Pdist,native -DskipTests -Dtar -Dcontainer-executor.conf.dir=/etc/hadoop
注意/etc/hadoop 是你以后container-executor.cfg文件的位置
编译完成
最新文件:/opt/hadoop-3.2.1-src01/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/target/native/target/usr/local/bin
传到HADOOP_HOME/bin下就可以了
我们在用root提交个任务试试
/opt/dtstack/Spark/spark_pkg/bin/spark-submit --class org.apache.spark.examples.SparkPi --master yarn --deploy-mode cluster --executor-cores 1 --queue default /opt/dtstack/Spark/spark_pkg/examples/jars/spark-examples_2.12-3.2.0.jar 10
chown root:hadoop container-executor
Chmod 6050 container-executor
解决