分配文件的格式分配文件必须是 XML 格式。这个格式包含五种元素:Queue 元素, 代表队列. 每个可能包含下面的属性:
minResources: minimum resources the queue is entitled to, in the form "X mb, Y vcores". For the single-resource fairness policy, the vcores value is ignored. If a queue's minimum share is not satisfied, it will be offered available resources before any other queue under the same parent. Under the single-resource fairness policy, a queue is considered unsatisfied if its memory usage is below its minimum memory share. Under dominant resource fairness, a queue is considered unsatisfied if its usage for its dominant resource with respect to the cluster capacity is below its minimum share for that resource. If multiple queues are unsatisfied in this situation, resources go to the queue with the smallest ratio between relevant resource usage and minimum. Note that it is possible that a queue that is below its minimum may not immediately get up to its minimum when it submits an application, because already-running jobs may be using those resources.
maxResources: maximum resources a queue is allowed, in the form "X mb, Y vcores". For the single-resource fairness policy, the vcores value is ignored. A queue will never be assigned a container that would put its aggregate usage over this limit.
maxRunningApps: limit the number of apps from the queue to run at once
weight: to share the cluster non-proportionally with other queues. Weights default to 1, and a queue with weight 2 should receive approximately twice as many resources as a queue with the default weight.
schedulingPolicy: to set the scheduling policy of any queue. The allowed values are "fifo"/"fair"/"drf" or any class that extendsorg.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.SchedulingPolicy. Defaults to "fair". If "fifo", apps with earlier submit times are given preference for containers, but apps submitted later may run concurrently if there is leftover space on the cluster after satisfying the earlier app's requests.
aclSubmitApps: a list of users that can submit apps to the queue. A (default) value of "*" means that any users can submit apps. A queue inherits the ACL of its parent, so if a queue2 descends from queue1, and user1 is in queue1's ACL, and user2 is in queue2's ACL, then both users may submit to queue2.
minSharePreemptionTimeout: number of seconds the queue is under its minimum share before it will try to preempt containers to take resources from other queues.
User 元素, 代表管理单独用户行为的设置。他们可以包含一个单独的属性: maxRunningApps, 指定用户的运行应用数量限制。
一个 userMaxAppsDefault 元素, 如果没有特别指定,设置了每个用户的默认运行应用限制。
一个 fairSharePreemptionTimeout 元素, 一个队列在尝试从其他队列抢占资源容器前,其公平分享下的秒数。
一个 defaultQueueSchedulingPolicy 元素, 为队列设置了默认的调度政策:如果在每个队列的schedulingPolicy 元素中指定就会被覆盖。默认是 "fair".
示例::::
<?xml version="1.0"?>
<allocations>
<queue name="sample_queue">
<minResources>10000 mb,0vcores</minResources>
<maxResources>90000 mb,0vcores</maxResources>
<maxRunningApps>50</maxRunningApps>
<weight>2.0</weight>
<schedulingPolicy>fair</schedulingPolicy>
<queue name="sample_sub_queue">
<minResources>5000 mb,0vcores</minResources>
</queue>
</queue>
<user name="sample_user">
<maxRunningApps>30</maxRunningApps>
</user>
<userMaxAppsDefault>5</userMaxAppsDefault>
</allocations>
注意,由于对之前的 FairScheduler 的后向兼容, "queue" 元素可以被 "pool" 元素代替.
管理
公平调度器提供了对运行时管理的两种机制的支持:
通过编辑分配文件,可以修改最低共享、限制、权重、预占有时间差和队列调度政策。调度器会在知道此文件修改了之后10-15秒后会重载它。
当前应用、队列和公平分享可以通过 ResourceManager的 web 界面检查,地址是 http://ResourceManager URL/cluster/scheduler.