Hadoop学习(二)——Capacity Scheduler学习

Hadoop学习(二)——Capacity Scheduler学习

目录:

1、Capacity Scheduler资源调度器的特点:

2、官方文档查看:

3、在Ambari上配置Resource Manager的Capacity Scheduler资源调度器:

4、结果展示:


1、Capacity Scheduler资源调度器的特点:

(1)当队列已满,Capacity Scheduler资源调度器不会强制释放Container,当一个队列资源不够用时,这个队列只能获得其它队列释放后的Container资源,即“弹性队列”。同时也可以为队列设置一个最大资源使用量,防止过多占用其他队列的资源。

(2)有一个专门的队列来运行小任务,但是为小任务专门设置一个队列会预先占用一定的集群资源,这就导致大任务的执行时间会落后于使用FIFO资源调度器的时间。

(3)在一个队列内部,资源的调度采用的是FIFO(先进先出)策略

 

2、官方文档查看:

CONFIGURING YARN CAPACITY SCHEDULER WITH APACHE AMBARI

In this tutorial we are going to explore how we can configure YARN Capacity Scheduler from Ambari.

YARN’s Capacity Scheduler is designed to run Hadoop applications in a shared, multi-tenant cluster while maximizing the throughput and the utilization of the cluster.

Traditionally each organization has it own private set of compute resources that have sufficient capacity to meet the organization’s SLA. This generally leads to poor average utilization. Also there is heavy overhead of managing multiple independent clusters.

Sharing clusters between organizations allows economies of scale . However, organizations are concerned about sharing a cluster in the fear of not getting enough available resources that are critical to meet their SLAs.

The Capacity Scheduler is designed to allow sharing a large cluster while giving each organization capacity guarantees. There is an added benefit that an organization can access any excess capacity not being used by others. This provides elasticity for the organizations in a cost-effective manner.

Sharing clusters across organizations necessitates strong support for multi-tenancy since each organization must be guaranteed capacity and safeguards to ensure the shared cluster is impervious to single rogue application or user or sets thereof. The Capacity Scheduler provides a stringent set of limits to ensure that a single application or user or queue cannot consume disproportionate amount of resources in the cluster. Also, the Capacity Scheduler provides limits on initialized/pending applications from a single user and queue to ensure fairness and stability of the cluster.

The primary abstraction provided by the Capacity Scheduler is the concept of queues. These queues are typically set up by administrators to reflect the economics of the shared cluster.

To provide further control and predictability on sharing of resources, the Capacity Scheduler supports hierarchical queues to ensure resources are shared among the sub-queues of an organization before other queues are allowed to use free resources, thereby providing affinity for sharing free resources among applications of a given organization.

对其进行翻译:

Apache Ambari中配置Yarn资源调度器Capacity Scheduler

在本教程中,我们将探索如何从Ambari中配置Yarn的Capacity Scheduler资源调度器。

Yarn的Capacity Scheduler资源调度器的设计是在共享的多租户集群中运行Hadoop应用程序,同时最大化集群的系统吞吐量和资源利用率。

传统上每一个组织有它自己的私有的一组计算资源,它们有足够的能力去满足这个组织的SLA(Service-Level Agreement)。这通常会导致平均资源利用率不高。此外,管理多个独立集群的开销很大。

在组织间共享集群资源允许规模经济。然而,组织关注的是共享集群这种方式,他们害怕共享集群不能够提供足够的资源去满足它们各自的SLA。

跨组织共享集群需要对多租户给予强有力的支持,因为每个组织必须保证其资源使用及安全防护,以确保共享集群不受单个流氓应用程序或者用户或者其组合的影响。Capacity Scheduler资源调度器提供了一组严格的限制来确保单个应用程序或者用户或者队列不会耗尽集群中不相称的大量资源。同时,Capacity Scheduler资源调度器对来自单个用户和队列中初始化/挂起的应用提供限制,以确保集群的公平性和稳定性。

Capacity Scheduler资源调度器提供的主要抽象概念是队列。这些队列通常由管理员设置,来反映共享集群的经济性。

Capacity Scheduler资源调度器的设计是允许共享一个大集群的资源,同时保证每个组织的资源供给。另一个好处是一个组织能够访问任何不被其他人使用的额外资源。这个好处以成本效益的方式为组织间提供了弹性。

为了给共享资源提供更进一步的控制和预测能力,Capacity Scheduler支持层次化队列调度,确保一个组织的子队列间其它队列可以使用空闲的共享资源,由此对于特定组织的应用程序之间共享空闲资源能提供最密切的使用。

 

3、在Ambari上配置Resource Manager的Capacity Scheduler资源调度器:

(1)点击YARN->Configs->查看Scheduler部分,修改配置yarn.resourcemanager.scheduler.class以及Capacity Scheduler部分。

 Hadoop学习(二)——Capacity Scheduler学习

图3.1 配置项截图

相关配置说明:

yarn.scheduler.capacity.maximum-am-resource-percent=0.5:集群中用于运行应用程序ApplicationMaster可以占用的资源队列最大百分比为50%,即限制当前处于活动状态的应用程序;

yarn.scheduler.capacity.maximum-applications=10000:集群或队列中同时处于等待和运行状态的应用程序数目上限为10000;

yarn.scheduler.capacity.node-locality-delay=40:调度器尝试调度的次数为40;

yarn.scheduler.capacity.queue-mappings-override.enable=false:不启用映射重写功能;

yarn.scheduler.capacity.root.accessible-node-labels=*:队列可以访问的标签列表,比如“spark,hbase”等,*表示通配符;

yarn.scheduler.capacity.root.acl_administer_queue=*:为队列指定一个管理员,该管理员可以控制该队列的所有应用程序,*表示所有用户都可以控制;

yarn.scheduler.capacity.root.capacity=100:root队列容量百分比为100%,在每个级别上,所有队列的容量和必须等于100。如果有空闲资源提供弹性,队列中的应用程序可能会消耗比队列容量更多的资源;

yarn.scheduler.capacity.root.default.acl_submit_applications=*:限定哪些用户或用户组可以向default队列中提交应用程序,*表示所有用户;

yarn.scheduler.capacity.root.default.capacity=50:root队列的子队列default队列容量百分比为50%

yarn.scheduler.capacity.root.default.maximum-capacity=95:default队列资源的使用上限为95%

yarn.scheduler.capacity.root.default.ordering-policy=fifo:应用程序调度策略为先来先服务;

yarn.scheduler.capacity.root.default.state=RUNNING:default队列的状态,可以是RUNNING或STOPPED;

yarn.scheduler.capacity.root.default.user-limit-factor=1.9:每个用户最多可使用的资源量(百分比),如default.capacity设置为50,default.user-limit-factor设置为1.9,则default队列可以使用的最大容量是0.5 * 1.9 = 0.95;

yarn.scheduler.capacity.root.query.acl_administer_queue=*

yarn.scheduler.capacity.root.query.acl_submit_applications=*

yarn.scheduler.capacity.root.query.capacity=50

yarn.scheduler.capacity.root.query.maximum-capacity=95

yarn.scheduler.capacity.root.query.minimum-user-limit-percent=100

yarn.scheduler.capacity.root.query.ordering-policy=fifo

yarn.scheduler.capacity.root.query.state=RUNNING

yarn.scheduler.capacity.root.query.user-limit-factor=1.9

yarn.scheduler.capacity.root.queues=default,query:Capacity Scheduler已经预定了一个队列为root,系统中所有的queue都是root队列的子节点,其它的queues列表在这里用“,”分割。

(2)也可以在Ambari界面右上角通过Yarn Queue Manager界面查看或修改Capacity Scheduler资源调度器的相关参数:

 Hadoop学习(二)——Capacity Scheduler学习

图3.2 Yarn Queue Manager管理界面

 Hadoop学习(二)——Capacity Scheduler学习

图3.3 Scheduler页面配置项

定义解释:

A)Calculator:资源计算方法,其有两种形式:

①Default Resource Calculator:只会计算内存

②Dominant Resource Calculator:会计算内存和CPU

Maximum Applications:所有队列中的最大

B)多租户:实现多用户的环境下共用相同的系统或程序组件,共享一个集群,同时给予每一个租户计算能力的保证。利用多租户带来的资源高度共享模式,提高资源利用率,降低单位资源成本的同时,也要能够确保各租户间数据的隔离性。其有如下特点:

①租户间共享资源越多的架构,租户隔离难度越大,成本越高。

②在单位资源成本和租户隔离成本取最佳平衡点,就能找到最合理的架构。

C)队列:Capacity Scheduler资源调度器可以理解为一个个的资源队列,资源队列是通过用户去分配的。每一个队列会设置一个资源的占比保证容量,每个队列有严格的访问控制,各个租户只能向自己的队列里面提交任务,而不能修改或访问其他队列的任务。同时空闲的资源可以被分配给任何队列。


4、结果展示:

在Yarn Web界面Scheduler中可以查看到弹性队列配置成功,query队列资源不够用时会分配到default队列中空闲的资源:

 Hadoop学习(二)——Capacity Scheduler学习

图4.1 结果展示