配置公平调度器
在这一步中,我们将配置公平调度器(Fair Scheduler),以确保王国公民之间的资源公平分配。
首先,在 /home/hadoop
目录下为公平调度器创建一个新的配置文件 fair-scheduler.xml
:
<!-- /home/hadoop/fair-scheduler.xml -->
<?xml version="1.0"?>
<allocations>
<defaultQueueSchedulingPolicy>fair</defaultQueueSchedulingPolicy>
<queue name="root">
<weight>1.0</weight>
<queue name="citizens">
<weight>1.0</weight>
<minResources>1024 mb, 1 vcores</minResources>
</queue>
<queue name="priests">
<weight>2.0</weight>
<minResources>2048 mb, 2 vcores</minResources>
</queue>
</queue>
</allocations>
在此配置中,我们定义了两个队列:citizens
和 priests
。citizens
队列的权重为 1.0,最小资源分配为 1024 MB 内存和 1 个 vcore。priests
队列的权重为 2.0,最小资源分配为 2048 MB 内存和 2 个 vcore。
接下来,通过运行以下命令应用新配置:
yarn scheduler --setConf /home/hadoop/fair-scheduler.xml
再次运行 yarn scheduler -getConf
命令,验证公平调度器是否已激活。