스케줄링 설정
YARN 스케줄러 설정
YARN의 기본 스케줄러인 커패서티 스케줄러(Capacity Scheduler)와 페어 스케줄러(Fair Scheduler)를 설정하는 방법은 다음과 같습니다.
스케줄러 유형 정의
Capacity Scheduler
Capacity Scheduler는 YARN의 기본 스케줄러로, 트리 형태의 큐를 선언하고 큐별로 사용 가능한 용량을 할당하여 YARN의 리소스를 관리합니다.
Capacity Scheduler 설정 키
| 설정 키 | 설정값 |
|---|---|
| yarn.scheduler.capacity.maximum-applications | PREP, RUNNING 상태로 설정될 수 있는 애플리케이션의 최대 개수 |
| yarn.scheduler.capacity.maximum-am-resource-percent | 애플리케이션 마스터(AM)에 할당 가능한 최대 비율 설정 |
| yarn.scheduler.capacity.root.queues | root 큐에 등록하는 하부 큐의 이름 등록 |
| yarn.scheduler.capacity.root.[큐이름].maximum-am-resource-percent | 큐에서 AM이 사용할 수 있는 리소스의 비율 |
| yarn.scheduler.capacity.root.[큐이름].capacity | 큐의 용량 비율 |
| yarn.scheduler.capacity.root.[큐이름].user-limit-factor | 큐에 설정된 limit-factor만큼 다른 큐의 용량을 사용할 수 있으나, maximum-capacity 이상으로는 사용할 수 없음 |
| yarn.scheduler.capacity.root.[큐이름].maximum-capacity | 큐가 최대로 사용할 수 있는 용량 |
Capacity Scheduler 설정
<configuration>
<property>
<name>yarn.scheduler.capacity.maximum-applications</name>
<value>10000</value>
</property>
<property>
<name>yarn.scheduler.capacity.maximum-am-resource-percent</name>
<value>0.1</value>
</property>
<property>
<name>yarn.scheduler.capacity.resource-calculator</name>
<value>org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator</value>
</property>
<property>
<name>yarn.scheduler.capacity.root.queues</name>
<value>prd,stg</value>
</property>
<property>
<name>yarn.scheduler.capacity.root.prd.capacity</name>
<value>80</value>
</property>
<property>
<name>yarn.scheduler.capacity.root.stg.capacity</name>
<value>20</value>
</property>
<property>
<name>yarn.scheduler.capacity.root.prd.user-limit-factor</name>
<value>1</value>
</property>
<property>
<name>yarn.scheduler.capacity.root.stg.user-limit-factor</user-limit-factor</name>
<value>2</value>
</property>
<property>
<name>yarn.scheduler.capacity.root.prd.maximum-capacity</name>
<value>100</value>
</property>
<property>
<name>yarn.scheduler.capacity.root.stg.maximum-capacity</name>
<value>30</value>
</property>
</configuration>
Fair Scheduler
Fair Scheduler는 제출된 작업이 리소스를 균등하게 점유할 수 있도록 지원합니다. 큐에 작업이 제출되면 클러스터는 리소스를 조절하여 모든 작업에 균등하게 리소스를 할당합니다.
| Fair scheduler의 설정 키 | 설정값 |
|---|---|
| yarn.scheduler.fair.allocation.file | Fair Scheduler 설정 파일의 이름 |
| yarn.scheduler.fair.user-as-default-queue | 큐 이름을 지정하지 않았을 때 기본 큐 사용 여부 |
| yarn.scheduler.fair.preemption | 우선순위 선점의 사용 여부 |
Fair Scheduler 설정 예제
<?xml version="1.0"?>
<allocations>
<queue name="dev">
<minResources>10000 mb,10vcores</minResources>
<maxResources>60000 mb,30vcores</maxResources>
<maxRunningApps>50</maxRunningApps>
<maxAMShare>1.0</maxAMShare>
<weight>2.0</weight>
<schedulingPolicy>fair</schedulingPolicy>
</queue>
<queue name="prd">
<minResources>10000 mb,10vcores</minResources>
<maxResources>60000 mb,30vcores</maxResources>
<maxRunningApps>100</maxRunningApps>
<maxAMShare>0.1</maxAMShare>
<weight>2.0</weight>
<schedulingPolicy>fair</schedulingPolicy>
<queue name="sub_prd">
<aclSubmitApps>charlie</aclSubmitApps>
<minResources>5000 mb,0vcores</minResources>
</queue>
</queue>
<user name="sample_user">
<maxRunningApps>30</maxRunningApps>
</user>
<userMaxAppsDefault>5</userMaxAppsDefault>
<queueMaxAMShareDefault>0.2</queueMaxAMShareDefault>
<queuePlacementPolicy>
<rule name="specified"/>
<rule name="primaryGroup" create="false"/>
<rule name="default" queue="dev"/>
</queuePlacementPolicy>
</allocations>
스케줄러 변경
Hadoop Eco의 기본 스케줄러는 Capacity Scheduler입니다. Fair Scheduler로 변경하려면 yarn-site.xml 설정을 변경한 후 서비스를 재시작해야 합니다.
스케줄러 변경 예제
<!--- 커패시티 스케줄러 --->
<property>
<name>yarn.resourcemanager.scheduler.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>
</property>
<!--- 페어 스케줄러 --->
<property>
<name>yarn.resourcemanager.scheduler.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
</property>
스케줄러 설정 변경
큐별 설정을 변경하는 경우, ResourceManager가 실행 중인 상태에서도 설정을 적용할 수 있습니다. XML 파일의 설정을 변경한 후 다음 명령을 실행합니다.
스케줄러 설정 변경 예제
yarn rmadmin -refreshQueues