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

简介: 开启 Kerberos 安全的大数据环境中,Yarn Container 启动失败导致作业失败

大数据问题排查系列 - 开启 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.

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)

本文由 mdnice 多平台发布

相关实践学习
基于MaxCompute的热门话题分析
本实验围绕社交用户发布的文章做了详尽的分析,通过分析能得到用户群体年龄分布,性别分布,地理位置分布,以及热门话题的热度。
SaaS 模式云数据仓库必修课
本课程由阿里云开发者社区和阿里云大数据团队共同出品,是SaaS模式云原生数据仓库领导者MaxCompute核心课程。本课程由阿里云资深产品和技术专家们从概念到方法,从场景到实践,体系化的将阿里巴巴飞天大数据平台10多年的经过验证的方法与实践深入浅出的讲给开发者们。帮助大数据开发者快速了解并掌握SaaS模式的云原生的数据仓库,助力开发者学习了解先进的技术栈,并能在实际业务中敏捷的进行大数据分析,赋能企业业务。 通过本课程可以了解SaaS模式云原生数据仓库领导者MaxCompute核心功能及典型适用场景,可应用MaxCompute实现数仓搭建,快速进行大数据分析。适合大数据工程师、大数据分析师 大量数据需要处理、存储和管理,需要搭建数据仓库?学它! 没有足够人员和经验来运维大数据平台,不想自建IDC买机器,需要免运维的大数据平台?会SQL就等于会大数据?学它! 想知道大数据用得对不对,想用更少的钱得到持续演进的数仓能力?获得极致弹性的计算资源和更好的性能,以及持续保护数据安全的生产环境?学它! 想要获得灵活的分析能力,快速洞察数据规律特征?想要兼得数据湖的灵活性与数据仓库的成长性?学它! 出品人:阿里云大数据产品及研发团队专家 产品 MaxCompute 官网 https://www.aliyun.com/product/odps 
相关文章
|
1天前
|
人工智能 安全 算法
AI与大数据:智慧城市安全的护航者与变革引擎
AI与大数据:智慧城市安全的护航者与变革引擎
37 1
|
1天前
|
SQL 分布式计算 监控
MaxCompute提供了一些工具以帮助您监控作业和资源使用情况。
【2月更文挑战第4天】MaxCompute提供了一些工具以帮助您监控作业和资源使用情况。
32 8
|
1天前
|
资源调度 前端开发 大数据
大数据的yarn和前端的yarn冲突解决
大数据的yarn和前端的yarn冲突解决
|
1天前
|
分布式计算 DataWorks Java
DataWorks产品使用合集之阿里云DataWorks专有云环境下,上传MaxCompute的UDF(用户自定义函数)的JAR包的步骤如何解决
DataWorks作为一站式的数据开发与治理平台,提供了从数据采集、清洗、开发、调度、服务化、质量监控到安全管理的全套解决方案,帮助企业构建高效、规范、安全的大数据处理体系。以下是对DataWorks产品使用合集的概述,涵盖数据处理的各个环节。
22 0
|
1天前
|
安全 算法 大数据
漫谈大数据时代的个人信息安全(四)——“位所欲为”
漫谈大数据时代的个人信息安全(四)——“位所欲为”
|
1天前
|
安全 算法 大数据
漫谈大数据时代的个人信息安全(三)——“点赞之交”
漫谈大数据时代的个人信息安全(三)——“点赞之交”
|
1天前
|
机器学习/深度学习 人工智能 安全
漫谈大数据时代的个人信息安全(二)——“逢脸造戏”
漫谈大数据时代的个人信息安全(二)——“逢脸造戏”
|
1天前
|
安全 算法 大数据
漫谈大数据时代的个人信息安全(一)——“按图索骥”
漫谈大数据时代的个人信息安全(一)——“按图索骥”
|
1天前
|
资源调度 Kubernetes Java
Flink--day02、Flink部署(Yarn集群搭建下的会话模式部署、单作业模式部署、应用模式部署)
Flink--day022、Flink部署(Yarn集群搭建下的会话模式部署、单作业模式部署、应用模式部署)
154 5
|
1天前
|
缓存 Java 大数据
CDH大数据环境参数优化指南
CDH大数据环境参数优化指南

热门文章

最新文章

http://www.vxiaotou.com