一、介绍
- 类名:容量调度器
- org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler
- 配置文件
- 调度器级别的配置:在yarn-site.xml中
- 队列级别的配置:放在单独的文件中,文件名由yarn.scheduler.fair.allocation.file指定
二、配置项解析
-
调度器级别的配置
# 指定队列级别的配置项所在的文件名 yarn.scheduler.fair.allocation.file # 如果为true,在提交job没指定队列时,则会以用户名自动创建队列 yarn.scheduler.fair.user-as-default-queue # 如果为true,就可以为指定的队列不存在的job自动创建队列 yarn.scheduler.fair.allow-undeclared-pools # 是否自动根据job的大小来计算他的比重 yarn.scheduler.fair.sizebasedweight # 一个容器最多可以使用的内存数量 yarn.scheduler.maximum-allocation # 一个容器最多可以使用的虚拟CPU数量 yarn.scheduler.maximum-allocation-vcores
-
队列级别的配置举例
# 一个队列需要的最少资源 minResources # 一个队列最多能使用的资源 maxResources # 一个队列所分配的一个容器最多可使用的资源量 maxContainerAllocation # 可以分配为临时子队列的最大资源量 maxChildResources # 一个队列中对多能同时运行的job数量 maxRunningApps # 一个job的ApplicationMaster在一个队列中可以占用的最大资源比例 maxAMShare # 一个队列的比重 weight # 可以提交job到本队列的用户或组的列表 aclSubmitApps # 队列内的调度策略 schedulingPolicy
三、实例解析
<?xml version="1.0"?>
<allocations>
<!-- 定义一个根队列,名叫sample_queue -->
<queue name="sample_queue">
<minResources>10000 mb, 0vcores</minResources>
<maxResources>90000 mb, 0vcores</maxResources>
<maxRunningApps>50</maxRunningApps>
<maxAMShare>0.1</maxAMShare>
<weight>2.0</weight>
<schedulingPolicy>fair</schedulingPolicy>
<!-- 定义一个子队列 -->
<queue name="sample_sub_queue">
<aclSubmitApps>charlie</aclSubmitApps>
<minResources>5000 mb, 0vcores</minResources>
</queue>
<!-- 再定义一个子队列 -->
<queue name="sample_reservable_queue">
<reservation></reservation>
</queue>
</queue>
<queueMaxAMShareDefault>0.5</queueMaxAMShareDefault>
<queueMaxResourcesDefault>40000mb, 0vcores</queueMaxResourcesDefault>
<!-- 定义次队列是为了作为自动创建的队列的容器,类型为parent表示不是叶子队列 -->
<queue name="secondary_group_queue" type="parent">
<weight>3.0</weight>
<maxChildResources>4096 mb, 4vcores</maxChildResources>
</queue>
<user name="sample_user">
<maxRunningApps>30</maxRunningApps>
</user>
<userMaxAppsDefault>5</userMaxAppsDefault>
<!-- 列出一些规则,根据这些规则决定将一个job放在哪个队列中 -->
<queuePlacementPolicy>
<rule name="specified" />
<rule name="primaryGroup" create="false" />
<rule name="nestedUserQueue">
<rule name="secondaryGroupExistingQueue" create="false" />
</rule>
<rule name="default" queue="sample_queue"/>
</queuePlacementPolicy>
</allocations>