概述:

目前,Hadoop作业调度器主要有三种:FIFO(first in first out)、Capacity Scheduler和Fair Scheduler。Hadoop3.1.3默认的资源调度器是Capacity Scheduler。
具体设置详见:yarn-default.xml文件

  1. <property>
  2. <name>yarn.resourcemanager.scheduler.class</name>
  3. <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>
  4. <description>The class to use as the resource scheduler.</description>
  5. </property>

分类:

先进先出调度器(FIFO)

image.png

容量调度器(Capacity Scheduler)

下图总结:

  1. 先选择队列:最闲的(比例最小)
  2. 再将新任务分配到队列中的某个位置(优先级、时间、用户资源量限制、内存限制)

image.png

公平调度器(Fair Scheduler)

image.png
image.png

job21image.png

image.png

image.png

3)选择容器

image.png

容量资源调度器案例

需求

  1. Yarn默认的容量调度器是一条单队列的调度器,在实际使用中会出现单个任务阻塞整个队列的情况。同时,随着业务的增长,公司需要分业务限制集群使用率。这就需要我们按照业务种类配置多条任务队列。

配置多队列的容量调度器

默认Yarn的配置下,容量调度器只有一条Default队列。在capacity-scheduler.xml中可以配置多条队列,并降低default队列资源占比:

  1. <!-- 红色是修改的部分-->
  2. <property>
  3. <name>yarn.scheduler.capacity.root.queues</name>
  4. <value>default,hive</value>
  5. <description>
  6. The queues at the this level (root is the root queue).
  7. </description>
  8. </property>
  9. <property>
  10. <name>yarn.scheduler.capacity.root.default.capacity</name>
  11. <value>40</value>
  12. </property>
  13. <!-- 同时为新加队列添加必要属性:-->
  14. <property>
  15. <name>yarn.scheduler.capacity.root.hive.capacity</name>
  16. <value>60</value>
  17. </property>
  18. <property>
  19. <name>yarn.scheduler.capacity.root.hive.user-limit-factor</name>
  20. <value>1</value>
  21. </property>
  22. <property>
  23. <name>yarn.scheduler.capacity.root.hive.maximum-capacity</name>
  24. <value>80</value>
  25. </property>
  26. <property>
  27. <name>yarn.scheduler.capacity.root.hive.state</name>
  28. <value>RUNNING</value>
  29. </property>
  30. <property>
  31. <name>yarn.scheduler.capacity.root.hive.acl_submit_applications</name>
  32. <value>*</value>
  33. </property>
  34. <property>
  35. <name>yarn.scheduler.capacity.root.hive.acl_administer_queue</name>
  36. <value>*</value>
  37. </property>
  38. <property>
  39. <name>yarn.scheduler.capacity.root.hive.acl_application_max_priority</name>
  40. <value>*</value>
  41. </property>
  42. <property>
  43. <name>yarn.scheduler.capacity.root.hive.maximum-application-lifetime</name>
  44. <value>-1</value>
  45. </property>
  46. <property>
  47. <name>yarn.scheduler.capacity.root.hive.default-application-lifetime</name>
  48. <value>-1</value>
  49. </property>

在配置完成后,重启Yarn,就可以看到两条队列:
image.png