一、[Yarn资源调度之多租户的资源隔离配置]
### --- Yarn多租户资源隔离配置
~~~ Yarn集群资源设置为A,B两个队列,
~~~ A队列设置占用资源70%主要用来运行常规的定时任务,
~~~ B队列设置占用资源30%主要运行临时任务,
~~~ 两个队列间可相互资源共享,假如A队列资源占满,B队列资源比较充裕,
~~~ A队列可以使用B队列的资源,使总体做到资源利用最大化.
~~~ 选择使用Fair Scheduler调度策略!!
二、具体配置
### --- yarn-site.xml
[root@linux121 ~]# vim /opt/yanqi/servers/hadoop-2.9.2/etc/hadoop/yarn-site.xml
<!-- 指定我们的任务调度使用fairScheduler的调度方式 -->
<property>
<name>yarn.resourcemanager.scheduler.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
<description>In case you do not want to use the defaultscheduler</description>
</property>
### --- 发送到其它节点
[root@linux121 ~]# rsync-script /opt/yanqi/servers/hadoop-2.9.2/etc/hadoop/yarn-site.xml
### --- 创建fair-scheduler.xml文件
~~~ 在Hadoop安装目录/etc/hadoop创建该文件
~~~ # 创建fair-scheduler.xml文件
[root@linux121 ~]# vim /opt/yanqi/servers/hadoop-2.9.2/etc/hadoop/fair-scheduler.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<allocations>
<defaultQueueSchedulingPolicy>fair</defaultQueueSchedulingPolicy>
<queue name="root" >
<queue name="default">
<aclAdministerApps>*</aclAdministerApps>
<aclSubmitApps>*</aclSubmitApps>
<maxResources>9216 mb,4 vcores</maxResources>
<maxRunningApps>100</maxRunningApps>
<minResources>1024 mb,1vcores</minResources>
<minSharePreemptionTimeout>1000</minSharePreemptionTimeout>
<schedulingPolicy>fair</schedulingPolicy>
<weight>7</weight>
</queue>
<queue name="queue1">
<aclAdministerApps>*</aclAdministerApps>
<aclSubmitApps>*</aclSubmitApps>
<maxResources>4096 mb,4vcores</maxResources>
<maxRunningApps>5</maxRunningApps>
<minResources>1024 mb, 1vcores</minResources>
<minSharePreemptionTimeout>1000</minSharePreemptionTimeout>
<schedulingPolicy>fair</schedulingPolicy>
<weight>3</weight>
</queue>
</queue>
<queuePlacementPolicy>
<rule create="false" name="specified"/>
<rule create="true" name="default"/>
</queuePlacementPolicy>
</allocations>
### --- 发送到其它节点
[root@linux121 ~]# rsync-script /opt/yanqi/servers/hadoop-2.9.2/etc/hadoop/fair-scheduler.xml
### --- 重启yarn集群
[root@linux123 ~]# stop-yarn.sh
[root@linux123 ~]# start-yarn.sh
三、界面验证http://linux123:8088/cluster/scheduler:Scheduler
![](https://i-blog.csdnimg.cn/blog_migrate/a341c2de3cb54868a991662f088a192d.png)