您的位置:首页 > 汽车 > 新车 > Hadoop-YARN-Tutorial

Hadoop-YARN-Tutorial

2024/9/4 2:31:02 来源:https://blog.csdn.net/weixin_48935611/article/details/140224805  浏览:    关键词:Hadoop-YARN-Tutorial

Hadoop-YARN-Tutorial

在这里插入图片描述

1 What is YARN?

Yarn is the acronym for yet another resource negotiator.
Yarn是yet another resource negotiator的缩写。

Yarn is a resource manager created by separating the processing engine and the management function of mapreduce.
Yarn是通过分离mapreduce处理引擎和管理功能创建的资源管理器。

在这里插入图片描述

Monitors and manages workloads maintains a multi-tenant environment,manages the high availability features of hadoop and implements security controls.

监控和管理工作负载,维护多租户环境,管理hadoop的高可用性特性,并实现安全控制。


2.Need For YARN

在2012年之前,用户可以使用Java、python和ruby等脚本语言编写mapreduce程序,也可以使用pig(一种用于转换数据的语言)
在这里插入图片描述

无论使用何种语言,其实现都依赖于mapreduce处理模型。


在2012年5月hadoop 2.0版本发布期间,引入了yarn.。

不再局限于使用mapreduce框架,因为yarn除了支持mapreduce之外,还支持多种处理模型,比如spark。

在这里插入图片描述

在这里插入图片描述
Other features of yarn include significant performance improvement and a flexible execution engine
Yarn的其他特性包括显著的性能提升和灵活的执行引擎.


3.YARN-Use Case

雅虎(YAHOO!)是第一个拥抱hadoop的公司,并成为hadoop生态系统的潮流引领者.

In late 2012,yahoo struggled to handle iterative and stream processing of data on the hadoop infrastructure due to mapreduce limitations

2012年底,由于mapreduce的限制,雅虎在hadoop基础设施上处理迭代和流处理数据时遇到了困难。

Both iterative and stream processing were important to yahoo in facilitating its move from batch computing to continuous computing
迭代处理和流处理对于雅虎从批处理转向连续计算非常重要.

在这里插入图片描述

在 2013 年第一季度实施 yarn 之后,雅虎在 spark 上安装了 3 万多个生产节点,用于迭代处理。

  • 用于迭代处理的 spark

  • 用于流处理的 storm

  • 用于批处理的 hadoop

Allow it to handle more than 100 billion events such as clicks, impressions, email content ,metadata and so on per day.

这使其每天能够处理超过 1000 亿个事件,如点击、印象、电子邮件内容、元数据等。

This was possible only after yarn was introduced and multiple processing frameworks were implemented.

这只有在引入yarn并实现多个处理框架后才可能实现


4.YARN-Advantages

the single cluster approach provides a number of advantages
单集群方法具有以下优势:
在这里插入图片描述

  • 集群利用率更高,一个框架未使用的资源可由另一个框架使用

  • 降低运营成本,因为只需管理一个集群即可完成所有工作

  • 减少数据移动,因为无需在不同计算机集群上运行的 hadoop 纱线和系统之间移动数据


5.YARN Infrastructure

The yarn infrastructure is responsible providing computational resources such as cpu or memory needed for application executions.
Yarn基础设施负责提供计算资源,如执行应用程序所需的 CPU 或内存。

Yarn的基础设施和hdfs是完全独立的。Yarn infrastructure and hdfs are completely independent.

前者为运行应用程序提供资源,而后者提供存储。The former provides resources for running an application while the latter provides storage.

在这里插入图片描述

Mapreduce框架只是运行在yarn上的众多框架之一。The mapreduce framework is only one of the many possible frameworks that run on yarn.

The fundamental idea of mapreduce version 2 is to split the two major functionalities of resource management and job scheduling and monitoring into separate demons.

✔✔✔✔✔✔
mapreduce版本2的核心思想是将资源管理和作业调度与监控这两个主要功能分开。


6.Three Elements of YARN Architecture

The three important elements of the yarn architecture are Resource Manager ,Application Master ,and Node Manager

在这里插入图片描述

  • Resouce Manager

    • 通常每个集群都有一个资源管理器(rm),即master server主服务器.
      The resource manager or rm which is usually one per cluster is the master server

    • RM资源管理器知道数据节点的位置以及它们有多少资源.
      Resource manager knows the location of the data node and how many resources they have

    • 这一信息被称为机架感知.This information is referred to as rack awareness.

    • rm 运行几项服务,其中最重要的是资源调度程序(resource scheduler),它决定如何分配资源。
      The rm runs several services,the most important of which is the resource scheduler that decides how to assign the resources.

在这里插入图片描述


  • Application Master
    • Application Master是一个特定于框架的进程,负责为单个应用协商资源。
    • 每个Application Master从RM资源管理器请求资源,然后使用NM节点管理器提供的容器。
      Each application master requests resources from the resource manager and then works with the containers provided by node managers.

在这里插入图片描述
在这里插入图片描述


  • Node Manager
    • 一个集群中可以有多个节点管理器,他们是基础设施的工作节点
      the node managers can be many in one cluster,they are the slaves of the infrastructure.

    • 当它启动时,它会向 RM资源管理器 宣布自己的存在,并定期向 rm 发送心跳信息。
      When it starts it announces itself to the rm and periodically sends a heartbeat to the rm.

    • 每一个Node Manager都会向集群提供资源。 Each node manager offers resources to the cluster.

在这里插入图片描述

资源容量resource capacity是指内存容量和虚拟内核的 vcores 数量。

At runtime the resource scheduler decides how to use this capacity.运行时,RM资源调度器将决定如何使用这些资源。


Container is a fraction of the node manager capacity and it is used by the client to run a program.
容器是节点管理器容量的一部分,客户端使用它来运行程序.

在这里插入图片描述

Each NodeManager takes instructions from the ResourceManager, reports and handles containers on a single node.
每个 Node Manager 从 Resource Manager 接收指令,报告并处理单个节点上的容器。

在这里插入图片描述


1.Resouce Manager

  • RM在相互竞争的应用程序之间协调集群中的可用资源,以实现最大的集群利用率。
    The rm mediates the available resources in the cluster among competing applications with the goal of maximum cluster utilization.

在这里插入图片描述

  • RM包括一个名为the YarnScheduler的可插拔调度器,它允许使用不同的策略来管理约束,如容量调度器、公平调度器和服务水平协议。
    It includes a plugable scheduler called the yarn scheduler which allows different policies for managing constraints such as capacity fairness and service level agreements.

  • 资源管理器有两个主要组件——调度程序scheduler 和应用程序管理器applications manager
    the resource manager has two main components——scheduler and applications manager

在这里插入图片描述

  • 调度器负责根据容量线索等共同约束条件为各种运行中的应用程序分配资源
    the scheduler is responsible for allocating resources to various running applications depending on the common constraints of capacities cues and so on

  • scheduler调度器不会监视或跟踪应用程序的状态,也不会在任何应用程序或硬件故障的情况下重新启动任务
    the scheduler does not monitor or track the status of the application also it does not restart the tasks in case of any application or hardware failures

在这里插入图片描述

  • 调度器根据应用程序的资源需求执行其功能
    the scheduler performs its function based on the resource requirements of the applications

  • 它是基于资源容器的抽象概念实现的,资源容器包含内存、CPU、磁盘和网络等元素
    it does so based on the abstract notion of a resource container that incorporates elements such as memory cpu disk and network

  • 调度器有一个策略插件,负责在各种队列和应用程序之间划分集群资源
    the scheduler has a policy plugin which is responsible for partitioning the cluster resources among various queues and applications

在这里插入图片描述

  • 当前的mapreduce调度器,如容量调度器和公平调度器就是该插件的一些例子
    the current mapreduce schedulers such as capacity scheduler and the fair scheduler are some examples of the plugin

  • 容量调度器支持分层提示,以实现更可预测的集群资源共享
    the capacity scheduler supports hierarchical cues to enable a more predictable sharing of cluster resources


  • 应用程序管理器是一个接口,它维护已提交、当前正在运行或已完成的应用程序列表
    the application manager is an interface which maintains a list of applications that have been submitted currently running or completed

在这里插入图片描述

  • Applications Manager应用程序管理器负责接受作业提交,协商第一个执行特定应用程序的容器,并在失败时重启应用程序主容器。
    The applications manager is responsible for accepting job submissions negotiating the first container for executing the application specific application master and restarting the application master container on failure在这里插入图片描述

在这里插入图片描述

  • 资源管理器通过一个名为 ClientService 的接口与客户端通信

  • 客户端可通过 ClientService 提交或终止应用程序,并获取有关调度队列或群集统计数据的信息

在这里插入图片描述

  • administrative requests are served by a separate interface called the admin service through which operators can get updated information about the cluster operation in parallel
    管理请求由名为管理服务的单独接口提供,操作员可通过该接口获取有关群集运行的最新并行信息

  • the resource tracker service receives node heartbeats from the node manager to track new or decommissioned nodes.
    资源跟踪器服务从节点管理器接收节点心跳,以跟踪新节点或退出的节点
    在这里插入图片描述

  • the nm liveliness monitor and nodes list manager keep an updated status of which nodes are healthy so that the scheduler and the resource tracker service can allocate work appropriately

  • 节点存活率监控器和节点列表管理器随时更新节点的健康状态,以便调度器和资源跟踪器服务能适当分配工作.
    在这里插入图片描述

  • the application master service manages application masters on all nodes keeping the scheduler informed.应用程序主控服务管理所有节点上的应用程序主控,并随时通知调度程序。
    在这里插入图片描述

  • the AM liveliness monitor keeps a list of application managers and their last heartbeat times to let the resource manager know what applications are healthy on the cluster
    AM 实时性监控器会保存一份应用程序管理器及其上次心跳时间的列表,以便让资源管理器了解群集上哪些应用程序是健康的

  • any application master that does not send a heartbeat within a certain interval is marked as dead and rescheduled to run on a new container
    任何在一定时间间隔内未发送心跳的应用程序主控都会被标记为死亡,并重新安排在新容器上运行.


2. HA

在这里插入图片描述

在Hadoop 2.4之前,资源管理器(Resource Manager)在YARN集群中是单点故障。
Before Hadoop 2.4, the Resource Manager in a YARN cluster was a single point of failure.

The High Availability (HA) feature introduces redundancy in the form of an active-standby Resource Manager pair to eliminate this single point of failure.
高可用性(HA)特性通过引入主备资源管理器对来消除单点故障,增加了冗余。

资源管理器的高可用性是通过主备架构实现的。
Resource HA is realized through an active-standby architecture.

At any point in time, one Resource Manager (RM) is active, while one or more RMs are in standby mode, ready to take over the active RM’s duties should any unexpected event occur.
在任何时刻,一个资源管理器(RM)是活动的,而一个或多个RM处于待命状态,随时准备接管活动RM的工作,以应对任何意外情况。

切换到活动状态的触发条件可以是管理员通过命令行界面,或者通过集成的故障转移控制器。
The transition to active is triggered either by an administrator via the command-line interface or through the integrated failover controller.

RMs have the option to embed a ZooKeeper-based active-standby elector to determine which RM should be active.
资源管理器可以选择嵌入基于ZooKeeper的主备选举器来决定哪个RM应该是活动的。

当活动资源管理器故障或无响应时,另一个RM会自动选举为活动状态。
When the active RM fails or becomes unresponsive, another RM is automatically elected as the active RM.

It’s important to note that unlike HDFS, there is no need to run a separate ZKFC daemon here, as the embedded active-standby elector in the RM serves as both a failure detector and leader elector.

需要注意的是,与HDFS不同,这里不需要运行单独的ZKFC守护程序,因为嵌入在RM中的主备选举器充当了故障检测器和领导者选举器的角色。


3.Application Master

  • YARN中的应用程序主管是一个特定于框架的库

  • 用于与RM资源管理器协商资源,并与NM节点管理器或管理器一起执行和监视容器及其资源消耗。
    在这里插入图片描述

  • 在应用程序运行时,应用程序管理器负责管理应用程序的生命周期,动态调整资源消耗、执行流程和处理故障,并提供状态和指标。

  • 应用程序主管的架构设计旨在支持特定的框架,可以用任何语言编写,使用可扩展的通信协议与资源管理器和节点管理器交互。

  • 它可以定制以扩展框架功能或运行其他代码。由于应用程序主管不被视为可信的服务,因此不作为可信服务运行。

  • 实际上,每个应用程序都有自己的应用程序主管实例,但可以实现一个应用程序主管来管理一组应用程序,例如,用于Pig或Hive的应用程序主管来管理一组MapReduce作业。


4.NodeManger

当一个容器被分配给一个应用程序时,节点管理器会设置容器的运行环境,这包括根据租约指定的资源限制以及容器所需的数据或可执行文件等依赖关系。

  • 节点管理器监控节点的健康状态,一旦发现硬件或软件问题,会向资源管理器报告,以便调度器能够将资源重新分配到健康的节点,直到问题解决。

  • 节点管理器还为运行在节点上的容器提供多种服务,如日志聚合。

  • 它在每个节点上负责管理容器的整个生命周期、处理容器之间的依赖关系和租约,监控节点和容器的资源使用情况和健康状态,同时负责日志管理,并向资源管理器报告节点和容器的实时状态。

  • YARN容器是一组特定资源的集合,根据应用程序的需要由资源管理器分配到特定的节点上。

  • 应用程序管理器负责将容器分发给节点管理器,在被分配的节点上运行,从而使应用程序可以有效地访问所需资源。


5.YARN Container

YARN 容器是成功分配资源的结果,也就是说,RM 已向应用程序授予租约,允许其使用特定节点上的指定资源。
在这里插入图片描述

启动容器时,ApplicationMaster必须提供容器启动上下文(Container Launch Context, CLC),其中包括以下信息:

  • 环境变量
  • 依赖项,如数据文件或共享对象,在启动前需要的本地资源
  • 安全令牌
  • 创建应用程序想要启动的进程所需的命令

7.How YARN Runs an Application

在这里插入图片描述

1The client submits an application to the ResourceManager

客户端提交应用程序到ResourceManager:

  • 用户通过输入Hadoop的hadoop jar命令将应用程序提交给资源管理器。资源管理器负责维护集群上应用程序的列表和节点管理器上的可用资源。

在这里插入图片描述

2 The ResourceManager allocates a container

ResourceManager分配容器:

  • 资源管理器决定下一个将获得集群资源部分的应用程序,考虑到诸多约束条件,如队列容量、访问控制列表和公平性。

  • ResourceManager接收到应用程序的提交请求后,会分配一个或多个容器给该应用程序。容器是YARN中的基本执行单位,包含了执行应用程序所需的资源。
    在这里插入图片描述

3 The ApplicationMaster contacts the related NodeManager

ApplicationMaster联系相关的NodeManager:

  • 一旦容器被分配给应用程序,Application Master会与被分配容器的NodeManager建立联系。NodeManager是运行在集群节点上的代理,负责管理节点上的容器。
  • 当应用程序被接受后,资源管理器启动应用程序主管(Application Master)。应用程序主管负责管理该特定应用程序的整个生命周期。它向资源管理器发送资源请求以获取运行应用程序任务所需的容器,并协调容器的分配和任务的启动。
    在这里插入图片描述

4 The NodeManager launches the container

NodeManager启动容器:

  • NodeManager收到来自ApplicationMaster的请求后,会启动容器。容器启动过程包括设置容器的环境(包括环境变量、资源等)、拉取所需的依赖资源(如数据文件)、设置安全令牌等。
    在这里插入图片描述
  • 节点管理器负责管理分配给它的容器,包括启动容器中的任务。节点管理器监视容器中的资源使用情况,如内存和CPU份额。它会在必要时终止异常消耗资源的任务。

5 The container executes the ApplicationMaster

容器执行ApplicationMaster:

  • 一旦容器启动并设置好环境,容器内的进程即ApplicationMaster开始执行。ApplicationMaster的主要任务是协调与ResourceManager和NodeManager的通信,并管理应用程序的执行过程,包括任务调度、容器管理、失败处理等。

在这里插入图片描述

  • 应用程序主管在应用程序完成后关闭自身,并释放其使用的容器。资源管理器会检查应用程序主管的健康状态,如果应用程序主管失败,则资源管理器可以重新启动它以确保应用程序的连续运行。

整理不易~多多三连呀😂

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com