hadoop作业运行机制

1.前沿

 hadoop环境是cdh5.13  ,使用yarn作为资源管理器

 

2. 步骤详情

   2.1 作业提交

  • 当调用job.submit()/job.waitForCompletion() 时,向资源管理器请求一个应用ID,作为MapReduce作业ID
  • 根据程序配置的输入路径,计算作业的分片大小(该分片大小决定了map个数,map个数以及reduce个数 计算方式 见另一篇blog: mapreduce 作业中 map/reduce 个数的计算),如果输入路劲不存在,则直接抛出异常
  • 将运行任务所需要的资源(jar包,配置文件,计算所得的分片大小等)复制到共享文件系统(e.g. hdfs)
  • 调用资源管理器的submitApplication()方法提交作业

   2.2 初始化作业

  • 资源管理器接受到submigApplication()方法后,将请求交给yarn的调度器(Scheduler),该调度器在节点管理器分配容器,即在该容器中启动 appliction master 进程
  • 根据存储在共享文件系统中的分片大小,将路径中的文件划分成一个一个map分片,对每个map分片分配一个map任务,并且根据参数确定reduce任务个数

   2.3  任务分配以及执行

  • appliction master 为map任务和reduce任务向资源管理器请求容器(内存和cpu数),当然为map任务请求容器在前,reduce任务请求容器在后,为map请求容器需要考虑到数据的本地行
  • 资源管理器为任务分配了特定的容器后,application master就通过与节点管理器通信来启动容器。(执行任务之前需要将任务需要的资源包括配置文件,jar包等本地化)

3. yarn架构图以及hadoop作业提交

   3.1  yarn 架构图

         具体resourceManager 和 nodemanager的组成和作用 解释如下:(没有翻译,也较简单,大家可以自己看,原文链接:http://hadoop.apache.org/docs/r2.5.2/hadoop-yarn/hadoop-yarn-site/YARN.html

     The ResourceManager has two main components: Scheduler and ApplicationsManager.

   The Scheduler is responsible for allocating resources to the various running applications subject to familiar constraints of capacities, queues etc. The Scheduler is pure scheduler in the sense that it performs no monitoring or tracking of status for the application. Also, it offers no guarantees about restarting failed tasks either due to application failure or hardware failures. The Scheduler performs its scheduling function based the resource requirements of the applications; it does so based on the abstract notion of a resource Container which incorporates elements such as memory, cpu, disk, network etc. In the first version, only memory is supported.

   The ApplicationsManager is responsible for accepting job-submissions, negotiating the first container for executing the application specific ApplicationMaster and provides the service for restarting the ApplicationMaster container on failure.(备注:即管理application master )

The per-application ApplicationMaster has the responsibility of negotiating appropriate resource containers from the Scheduler, tracking their status and monitoring for progress.(applicationMaster 负责向scheduler申请资源,拿到资源“列表”,到指定的nodemanager "交流" 分配 contains,并且监控contains的状态 )

 

     The NodeManager is the per-machine framework agent who is responsible for containers(备注:实际的分配还是在node manager上 即contains 是在node manager上分配的), monitoring their resource usage (cpu, memory, disk, network) and reporting the same to the ResourceManager/Scheduler.

    (这样做的目的 是让各个组件 各司其职,且每个组建负责的部分不会“太重”,shedule 仅仅负责调度,获取资源列表 ;applicationMaster 像shedule 申请资源/contains 并且监控各个contains运行 ;nodemanager 是每台机器的资源“代理”,负责具体的资源分配,并且监控所属机器的资源使用情况;ApplicationManager 负责监控首次启动的ApplictionMaster进程,必要时提供重启)

 

3.2  hadoop 作业提交架构图

      

 该图片来源于hadoop 权威指南 第四版 第七章

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值