hadoop使用LinuxContainerExecutor后使用root用户提交任务报错--源码修改

问题描述

在hadoop3.2.1的版本中,配置cgroup对yarn的cpu资源进行隔离之后,发现,使用root用户在yarn上提交任务时,无法提交成功,并会报错:

Runing as root is not allowed!

最后将这些错误在源码中搜索发现以下内容:

/**
 * Is the user a real user account?
 * Checks:
 *   1. Not root
 *   2. UID is above the minimum configured.
 *   3. Not in banned user list
 * Returns NULL on failure
 */
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;
  }  

原来是在源码里写明了在开启了LCE(LinuxContainerExecutor)后。LCE不能使用root用户提交任务,会检查user信息。

问题本质

user信息的检查会在org.apache.hadoop.mapreduce.job的init阶段执行。
Container启动的过程大致如下:
资源本地化——启动container——运行container——资源回收

问题解决

在\hadoop-3.2.1-src\hadoop-yarn-project\hadoop-yarn\hadoop-yarn-server\hadoop-yarn-server-nodemanager\src\main\native\container-executor\impl\container-executor.c 中,找到上述的代码片段,并注释如下:

/**
 * Is the user a real user account?
 * Checks:
 *   1. Not root
 *   2. UID is above the minimum configured.
 *   3. Not in banned user list
 * Returns NULL on failure
 */
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;
//  }
  char *min_uid_str = get_value(MIN_USERID_KEY);
  int min_uid = DEFAULT_MIN_USERID;
  if (min_uid_str != NULL) {
    char *end_ptr = NULL; 
 。。。。。。
 。。。。

然后将代码重新编译即可。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值