开启 Kerberos 安全的大数据环境中,Yarn Container 启动失败导致 spark/hive 作业失败

博客君
• 阅读 1333

大数据问题排查系列 - 开启 Kerberos 安全的大数据环境中,Yarn Container 启动失败导致 spark/hive 作业失败

前言

大家好,我是明哥!

最近在若干个不同客户现场,都遇到了
大数据集群中开启 Kerberos 后,spark/hive 作业提交到YARN 后,因 YARN Container 启动失败作业无法执行的情况,在此总结下背后的知识点,跟大家分享下,希望大家有所收获。

1 问题1问题现象

某客户现场,大数据集群中开启了 kerberos 安全认证,提交 hive on mr/hive on spark 任务给 yarn 后执行失败,查看 yarn web ui 可见报错信息:

Application xxx failed 2 times due to AM container for xxx exited with exitCode -1000
......
main : run as user is hs_cic
main : requested yarn user is hs_cic
User hs_cic not found 
Failing the application.

开启 Kerberos 安全的大数据环境中,Yarn Container 启动失败导致 spark/hive 作业失败

2 问题2问题现象

某客户现场,大数据集群中开启了 kerberos 安全认证,提交 spark on hive 任务给 yarn 后执行失败,查看 yarn web ui 可见报错信息:

main : run as user is app-user
main : requested yarn user is app-user
User app-user not found 
Failing the application.

3 问题分析

上述问题出现后,在分析过程中,笔者注意到,使用命令 yarn logs -applicationId xxx 查询作业详细日志时,查询不到任何相关日志 (以确认 yarn 已经开启了日志聚合 yarn.log-aggregation-enable),且查看 hdfs 文件系统时发现已经创建了该作业日志对应的目录但该目录下没有文件;

另外在 hive on mr/spark 作业失败的集群中,笔者留意到集群中启用了hive代理:hive.server2.enable.doAs=true.

结合 yarn web ui中的关键报错信息 "Application xxx failed 2 times due to AM container for xxx exited with exitCode -1000...
User hs_cic not found
Failing the application.",可以确认,是因为集群中 YARN nodeManager 节点上没有相关业务用户,所以启动 yarn container 失败,导致作业无法执行。

4 问题原因

  • 在没有开启 Kerberos 安全的集群里,启动 yarn container 进程时,yarn.nodemanager.container-executor.class 可以使用 DefaultContainerExecutor 或 LinuxContainerExecutor;
  • 在启用了Kerberos 安全的集群里,启动 yarn container 进程时,yarn.nodemanager.container-executor.class 只能使用 LinuxContainerExecutor,其在底层会使用 setuid 切换到业务用户以启动 container 进程,所以要求所有 nodemanager 节点必须有业务用户;
  • 当集群中仅仅在 KDC 中添加了业务用户,而没有在 yarn nodemanager 节点建立对应的业务用用户时,nodemanager 节点就会因为没有相关用户而无法启动 container进程,而作业也就会因为无法获取到 contariner 资源从而无法执行而报错了。

5 解决方案

  • 解决方案很简单,就是在集群中各个节点上(至少是yarn nodemanager 节点)使用命令 useradd 创建对应的业务用户即可(底层会创建相关用户和用户组并写入到文件/etc/passwd中);
  • 如果节点过多嫌弃操作麻烦的话,也可以配置使用 ldap 并在ldap中集中创建相关业务用户,注意是配置 NodeManager 从 LDAP 中查找相关用户,不是使用ldap认证相关用户(--enableldap vs --enableldapauth),具体细节这里不再赘述;
  • 针对 hive on mr/spark 的情形,也可以关闭 hive 的代理(hive.server2.enable.doAs=false),此时hiveserver2编译提交sql作业到yarn时,会使用系统用户 hive 的身份进行提交,由于cdh安装时已经自动在集群各节点创建了hdfs/yarn/hive等系统用户,所以执行不会有问题;

6 技术背景

  • DefaultContainerExecutor: When using the default value for yarn.nodemanager.container-executor.class,which is org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor, the launched container process has the same Unix user as the NodeManager,which normally is yarn;
  • LinuxContainerExecutor: The secure container executor on Linux environmentis org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor, this executor runs the containers as either the YARN user who submitted the application (when full security is enabled) or as a dedicated user (defaults to nobody) when full security is not enabled.
  • When full security is enabled, the LinuxContainerExecutor requires all user accounts to be created on the cluster nodes where the containers are launched. It uses a setuid executable that is included in the Hadoop distribution. The NodeManager uses this executable to launch and kill containers. The setuid executable switches to the user who has submitted the application and launches or kills the containers.
  • The LinuxContainerExecutor does have some requirements:If running in non-secure mode, by default, the LCE runs all jobs as user “nobody”. This user can be changed by setting “yarn.nodemanager.linux-container-executor.nonsecure-mode.local-user” to the desired user. However, it can also be configured to run jobs as the user submitting the job. In that case “yarn.nodemanager.linux-container-executor.nonsecure-mode.limit-users” should be set to false.
  • after integrating hadoop with openldap, hdfs/hive/sentry can find user in openldap, but yarn cannot(the only exceptional is yarn)
点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
美凌格栋栋酱 美凌格栋栋酱
6个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
1年前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Easter79 Easter79
3年前
sqoop从hive导入数据到mysql时出现主键冲突
今天在将一个hive数仓表导出到mysql数据库时出现进度条一直维持在95%一段时间后提示失败的情况,搞了好久才解决。使用的环境是HUE中的Oozie的workflow任何调用sqoop命令,该死的oozie的日志和异常提示功能太辣鸡了,最后发现是重复数据导致数据进入mysql表时出现主键冲突进而导致数据同步失败。(1)众所周知hive表是没有主键与索引
Jacquelyn38 Jacquelyn38
4年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Stella981 Stella981
3年前
Spark 配置连接hive 元数据库(mysql)
Spark连接hive元数据库(mysql)方法一:1)打开Hivemetastoreroot@head42~hiveservicemetastore&netstatano|grep9083???2)开启spark连接Mysq
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Stella981 Stella981
3年前
HIVE 时间操作函数
日期函数UNIX时间戳转日期函数: from\_unixtime语法:   from\_unixtime(bigint unixtime\, string format\)返回值: string说明: 转化UNIX时间戳(从19700101 00:00:00 UTC到指定时间的秒数)到当前时区的时间格式举例:hive   selec
3A网络 3A网络
2年前
5 步教你将 MRS 数据导入 DWS
5步教你将MRS数据导入DWSMapReduce服务(MapReduceService,简称MRS)是一个基于开源Hadoop生态环境而运行的大数据集群,对外提供大容量数据的存储和分析能力,可解决用户的数据存储和处理需求。用户可以将海量业务数据,存储在MRS的分析集群,即使用Hive/Spark组件保存。Hive/Spark的数据
Python进阶者 Python进阶者
1年前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这