@羲凡——只为了更好的活着
Hadoop 公平调度器(Fair Scheduler)配置
hadoop集群的资源配置是否合理,是检验hadoop运维人员基于公司业务对hadoop配置的熟练程度。下面我简单的说一下配置需要设置那些。
1.修改yarn-site.xml,添加下面参数
<!-- 指定使用公平资源调度器 -->
<property>
<name>yarn.resourcemanager.scheduler.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
</property>
<!-- 指定公平调度器的配置文件 -->
<property>
<name>yarn.scheduler.fair.allocation.file</name>
<value>/usr/local/package/hadoop-2.7.3/etc/hadoop/fair-scheduler.xml</value>
</property>
<!-- 在没指定队列时,不允许用名字做默认队列,默认为true -->
<property>
<name>yarn.scheduler.fair.user-as-default-queue</name>
<value>false</value>
</property>
<!-- 不允许队列抢占,默认为false -->
<property>
<name>yarn.scheduler.fair.preemption</name>
<value>false</value>
</property>
2.创建fair-scheduler.xml文件,设置参数
<?xml version="1.0"?>
<allocations>
<defaultQueueSchedulingPolicy>fair</defaultQueueSchedulingPolicy>
<queue name="root">
<queue name="big">
<weight>8</weight>
<minResources>10000 mb,10vcores</minResources>
<maxResources>300000 mb,180vcores</maxResources>
<maxRunningApps>100</maxRunningApps>
<schedulingPolicy>fair</schedulingPolicy>
</queue>
<queue name="small">
<weight>2</weight>
<minResources>10000 mb,10vcores</minResources>
<maxResources>30000 mb,30vcores</maxResources>
<maxRunningApps>50</maxRunningApps>
<schedulingPolicy>fifo</schedulingPolicy>
</queue>
</queue>
<queuePlacementPolicy>
<rule name="specified" create="false" />
<rule name="primaryGroup" create="false" />
<rule name="default" queue="root.big" />
</queuePlacementPolicy>
</allocations>
参数说明
weight:与其他队列不成比例地共享集群。权重默认为1,权重为8的队列接收的资源大约是默认权重队列的八倍。
minResources:队列有权使用的最小资源,格式为“x MB,y vcores”。
maxResources:队列分配的最大资源量,以绝对值(x MB,y vcores)表示。不会为队列分配将其聚合使用量超过此限制的容器。
maxRunningApps:限制队列中要同时运行的最大应用程序数
3.注意事项
a.每次修改fair-scheduler.xml文件不需要重启yarn集群,yarn会定时读取到该文件
b.如果允许队列间抢占,需要更多的设置,我下次说明
====================================================================
@羲凡——只为了更好的活着
若对博客中有任何问题,欢迎留言交流