Yarn核心参数配置案例

学习用的虚拟机中,修改核心参数前尽量先拍摄一个虚拟机快照,方便后面恢复成原始状态进行其他配置

例如:从 1G 数据中,统计每个单词出现次数。

服务器:3台,每台4G内存,每台4核4线程的CPU

分析:

1G / 128M(切片大小) = 8 个MapTask;

统计单词个数,可以输出到一个结果文件,即 1 个ReduceTask;

统计单词个数只需要一个MapReduce任务,所以 MRAppMaster 1个;

共计需要 8 + 1 + 1 = 10 个Container

平均每个 NodeManager 需要运行 : 10个 / 3 台 = 3 个任务(4 / 3 / 3)

修改yarn-site.xml配置:

  1. <property>
  2. <!-- 选择调度器,例如容量调度器 -->
  3. <description>The class to use as the resource scheduler.</description>
  4. <name>yarn.resourcemanager.scheduler.class</name>
  5. <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>
  6. </property>
  7. <property>
  8. <!-- ResourceManager处理器调度器请求的线程数量,默认50 -->
  9. <!-- 如果提交的任务数量大于50,可以增加该值,但是不能超过 3台 * 4线程 = 12 线程(去除其他应用程序,实际上不能超过8) -->
  10. <description>Number of threads to handle scheduler interface.</description>
  11. <name>yarn.resourcemanager.scheduler.client.thread-count</name>
  12. <value>8</value>
  13. </property>
  14. <property>
  15. <!-- 是否让yarn自动检测硬件进行配置,默认false -->
  16. <!-- 如果该节点有很多其他应用程序,建议手动配置 -->
  17. <!-- 如果该节点没有其他应用程序,可以采用自动配置 -->
  18. <description>Enable auto-detection of node capabilities such as memory and CPU.</description>
  19. <name>yarn.nodemanager.resource.detect-hardware-capabilities</name>
  20. <value>false</value>
  21. </property>
  22. <property>
  23. <!-- 是否将虚拟核数当做cpu核数,默认值false,采用物理核数 -->
  24. <description>Flag to determine if logical processors(such as
  25. hyperthreads) should be counted as cores. Only applicable on Linux
  26. when yarn.nodemanager.resource.cpu-vcores is set to -1 and
  27. yarn.nodemanager.resource.detect-hardware-capabilities is true.
  28. </description>
  29. <name>yarn.nodemanager.resource.count-logical-processors-as-cores</name>
  30. <value>false</value>
  31. </property>
  32. <property>
  33. <!-- 虚拟核数和物理核数乘数,默认值1.0 -->
  34. <!-- 此处我们的服务器时4核4线程,即核数和线程数比值为1.0 -->
  35. <description>Multiplier to determine how to convert phyiscal cores to
  36. vcores. This value is used if yarn.nodemanager.resource.cpu-vcores
  37. is set to -1(which implies auto-calculate vcores) and
  38. yarn.nodemanager.resource.detect-hardware-capabilities is set to true. The
  39. number of vcores will be calculated as
  40. number of CPUs * multiplier.
  41. </description>
  42. <name>yarn.nodemanager.resource.pcores-vcores-multiplier</name>
  43. <value>1.0</value>
  44. </property>
  45. <property>
  46. <!-- NodeManager使用内存,默认设置的 -1,即不开启硬件检测时默认8G,开启的话自动计算 -->
  47. <!-- 这里我们服务器是4G,需要调整为4G -->
  48. <description>Amount of physical memory, in MB, that can be allocated
  49. for containers. If set to -1 and
  50. yarn.nodemanager.resource.detect-hardware-capabilities is true, it is
  51. automatically calculated(in case of Windows and Linux).
  52. In other cases, the default is 8192MB.
  53. </description>
  54. <name>yarn.nodemanager.resource.memory-mb</name>
  55. <value>4096</value>
  56. </property>
  57. <property>
  58. <!-- NodeManager的CPU核数,默认值-1。即不开启硬件检测时默认8,开启的话自动计算-->
  59. <!-- 此处我们的服务器只有4核4线程 -->
  60. <description>Number of vcores that can be allocated
  61. for containers. This is used by the RM scheduler when allocating
  62. resources for containers. This is not used to limit the number of
  63. CPUs used by YARN containers. If it is set to -1 and
  64. yarn.nodemanager.resource.detect-hardware-capabilities is true, it is
  65. automatically determined from the hardware in case of Windows and Linux.
  66. In other cases, number of vcores is 8 by default.</description>
  67. <name>yarn.nodemanager.resource.cpu-vcores</name>
  68. <value>4</value>
  69. </property>
  70. <property>
  71. <!-- 容器最小内存,默认1G -->
  72. <description>The minimum allocation for every container request at the RM
  73. in MBs. Memory requests lower than this will be set to the value of this
  74. property. Additionally, a node manager that is configured to have less memory
  75. than this value will be shut down by the resource manager.</description>
  76. <name>yarn.scheduler.minimum-allocation-mb</name>
  77. <value>1024</value>
  78. </property>
  79. <property>
  80. <!-- 容器最大内存,默认8G -->
  81. <!-- 此处我们的服务器只有4G内存,根据前面分析,每台服务器要启动3个容器,所以容器最大内存可以修改为 2G -->
  82. <description>The maximum allocation for every container request at the RM
  83. in MBs. Memory requests higher than this will throw an
  84. InvalidResourceRequestException.</description>
  85. <name>yarn.scheduler.maximum-allocation-mb</name>
  86. <value>2048</value>
  87. </property>
  88. <property>
  89. <!-- 容器最小CPU核数,默认1个 -->
  90. <description>The minimum allocation for every container request at the RM
  91. in terms of virtual CPU cores. Requests lower than this will be set to the
  92. value of this property. Additionally, a node manager that is configured to
  93. have fewer virtual cores than this value will be shut down by the resource
  94. manager.</description>
  95. <name>yarn.scheduler.minimum-allocation-vcores</name>
  96. <value>1</value>
  97. </property>
  98. <property>
  99. <!-- 容器最大CPU核数,默认值4 -->
  100. <!-- 此处我们的服务器是4核,根据前面分析每台服务器要启动3个容器,所以容器最大CPU核数设置为2个 -->
  101. <description>The maximum allocation for every container request at the RM
  102. in terms of virtual CPU cores. Requests higher than this will throw an
  103. InvalidResourceRequestException.</description>
  104. <name>yarn.scheduler.maximum-allocation-vcores</name>
  105. <value>2</value>
  106. </property>
  107. <property>
  108. <!-- 虚拟内存检测,默认打开 -->
  109. <!-- 如果是 CentOS 7 + JDK 8,建议关闭该检测 -->
  110. <description>Whether virtual memory limits will be enforced for
  111. containers.</description>
  112. <name>yarn.nodemanager.vmem-check-enabled</name>
  113. <value>false</value>
  114. </property>
  115. <property>
  116. <!-- 虚拟内存和物理内存比例(用作虚拟内存检测的限制),默认值2.1 -->
  117. <description>Ratio between virtual memory to physical memory when
  118. setting memory limits for containers. Container allocations are
  119. expressed in terms of physical memory, and virtual memory usage
  120. is allowed to exceed this allocation by this ratio.
  121. </description>
  122. <name>yarn.nodemanager.vmem-pmem-ratio</name>
  123. <value>2.1</value>
  124. </property>

关闭虚拟内存检测的原因:
vmem.jpg
根据yarn.nodemanager.vmem-pmem-ration参数的配置的虚拟内存比例,该参数默认值是 2.1。即如果物理内存是 4G,Hadoop就会认为该节点上存在 8.4 G的虚拟内存的限制:vmemLimit = pmem * vmem-pmem-rationpmem:物理内存)。

在CentOS 7 + JDK 8时,Linux会为 Java 进程预留一部分虚拟内存(占了很大一部分),供 JDK 使用,但是 JDK 8没有使用这部分,而是使用了剩下的部分(即图上Java堆的部分),就导致浪费了很大的内存。而且因为剩下的这部分内存的量很少,不到4G,就会导致虚拟内存很容易超过了上限,如果实际使用的vmem超过了vmemLimit或者olderThanAge就可能 kill 掉该进程 。

修改yarn-site.xml后,分发到集群所有节点。

实际生产环境中,可能每天服务器节点的配置都不一样,需要为每个节点进行单独配置,不能直接复制分发。

然后重启yarn:

  1. sbin/stop-yarn.sh
  2. sbin/start-yarn.sh

浏览器查看相关配置信息:http://hadoop103:8088
容量调度器多队列提交案例

容量调度器一般在中小型公司中使用。

多队列配置

生产环境配置调度器多队列:

●调度器默认只有1个default队列,不能满足生产要求
●可以按照框架区分多队列,例如创建:hive队列、spark队列、flink队列等,每个框架的任务放入指定的队列(企业里面很少使用这中方式)
●可以按照业务模块区分多队列,例如创建:登录模块队列、购物车队列、下单队列、部门1队列、部门2队列等

创建多队列的优势:

●防止程序中出现递归死循环等代码,把所有的资源全部耗尽
●实现任务的 降级 使用,特殊时期可以保证重要的任务队列资源充足

例如:default队列占总内存 40% ,最大资源容量占总资源 60%(即不够的时候最多可以向其他队列借到60%);hive队列占总内存60%,最大资源容量占总资源 80%(即不够的时候最多可以向其他队列借到80%)。配置队列的优先级。

配置多队列的容量调度器,在 $HADOOP_HOME/etc/hadoop/capacity-scheduler.xml配置文件中配置。

在 capacity-scheduler.xml中修改配置:

  1. <!-- yarn.scheduler.capacity.root.queues前面的配置项保持默认即可 -->
  2. <property>
  3. <!-- 为容量调度器root指定多队列,默认值default -->
  4. <!-- 配置为 default,hive,即增加一个hive队列 -->
  5. <name>yarn.scheduler.capacity.root.queues</name>
  6. <value>default,hive</value>
  7. <description>
  8. The queues at the this level (root is the root queue).
  9. </description>
  10. </property>
  11. <property>
  12. <!-- root调度器下的default队列的内存容量,默认100% -->
  13. <!-- 根据前面的需求,调整为 40% -->
  14. <name>yarn.scheduler.capacity.root.default.capacity</name>
  15. <value>40</value>
  16. <description>Default queue target capacity.</description>
  17. </property>
  18. <property>
  19. <!-- hive队列的内存容量,默认没有该队列,需要增加 -->
  20. <!-- 根据前面的需求,调整为 60% -->
  21. <name>yarn.scheduler.capacity.root.hive.capacity</name>
  22. <value>40</value>
  23. <description>Default queue target capacity.</description>
  24. </property>
  25. <property>
  26. <!-- default队列中,单个用户最多占用的资源比例,默认1(即可以占用完default队列的所有资源) -->
  27. <!-- 可以根据实际需求进行调整,防止某一个用户的死循环等操作将整个队列资源全部耗尽 -->
  28. <name>yarn.scheduler.capacity.root.default.user-limit-factor</name>
  29. <value>1</value>
  30. <description>
  31. Default queue user limit a percentage from 0.0 to 1.0.
  32. </description>
  33. </property>
  34. <property>
  35. <!-- hive队列中,单个用户最多占用的资源比例。默认没有该队列,需要自行添加 -->
  36. <name>yarn.scheduler.capacity.root.default.user-limit-factor</name>
  37. <value>1</value>
  38. <description>
  39. Default queue user limit a percentage from 0.0 to 1.0.
  40. </description>
  41. </property>
  42. <property>
  43. <!-- default队列,最大可以占用的资源容量,默认100% -->
  44. <!-- 根据前面的需求,调整为60%(default队列的资源容量为40%,所以最大可以再向其他队列借调20%) -->
  45. <name>yarn.scheduler.capacity.root.default.maximum-capacity</name>
  46. <value>60</value>
  47. <description>
  48. The maximum capacity of the default queue.
  49. </description>
  50. </property>
  51. <property>
  52. <!-- hive队列,最大可以占用的资源容量,默认没有该队列,需要自行添加-->
  53. <name>yarn.scheduler.capacity.root.hive.maximum-capacity</name>
  54. <value>80</value>
  55. <description>
  56. The maximum capacity of the default queue.
  57. </description>
  58. </property>
  59. <property>
  60. <!-- default队列的状态,默认值RUNNING启动,不需要修改 -->
  61. <name>yarn.scheduler.capacity.root.default.state</name>
  62. <value>RUNNING</value>
  63. <description>
  64. The state of the default queue. State can be one of RUNNING or STOPPED.
  65. </description>
  66. </property>
  67. <property>
  68. <!-- hive队列的状态,默认没有该项,需要自行添加 -->
  69. <name>yarn.scheduler.capacity.root.hive.state</name>
  70. <value>RUNNING</value>
  71. <description>
  72. The state of the default queue. State can be one of RUNNING or STOPPED.
  73. </description>
  74. </property>
  75. <property>
  76. <!-- default队列任务提交的acl权限,默认*(即所有用户都可以向该队列进行提交),不需要调整 -->
  77. <name>yarn.scheduler.capacity.root.default.acl_submit_applications</name>
  78. <value>*</value>
  79. <description>
  80. The ACL of who can submit jobs to the default queue.
  81. </description>
  82. </property>
  83. <property>
  84. <!-- hive队列任务提交的acl权限,默认没有该队列,需要自行添加 -->
  85. <name>yarn.scheduler.capacity.root.hive.acl_submit_applications</name>
  86. <value>*</value>
  87. <description>
  88. The ACL of who can submit jobs to the default queue.
  89. </description>
  90. </property>
  91. <property>
  92. <!-- default队列操作管理的acl权限,默认*(即所有用户都可以对队列任务进行kill等操作),不需要调整 -->
  93. <name>yarn.scheduler.capacity.root.default.acl_administer_queue</name>
  94. <value>*</value>
  95. <description>
  96. The ACL of who can administer jobs on the default queue.
  97. </description>
  98. </property>
  99. <property>
  100. <!-- hive队列操作管理的acl权限,默认没有该队列,需要自行添加 -->
  101. <name>yarn.scheduler.capacity.root.hive.acl_administer_queue</name>
  102. <value>*</value>
  103. <description>
  104. The ACL of who can administer jobs on the default queue.
  105. </description>
  106. </property>
  107. <property>
  108. <!-- default队列的提交任务优先级设置的acl权限,默认*(即所有用户都可以设置队列中的优先级),不需要调整 -->
  109. <name>yarn.scheduler.capacity.root.default.acl_application_max_priority</name>
  110. <value>*</value>
  111. <description>
  112. The ACL of who can submit applications with configured priority.
  113. For e.g, [user={name} group={name} max_priority={priority} default_priority={priority}]
  114. </description>
  115. </property>
  116. <property>
  117. <!-- hive队列的提交任务优先级设置的acl权限,默认没有该队列,需要自行添加 -->
  118. <name>yarn.scheduler.capacity.root.hive.acl_application_max_priority</name>
  119. <value>*</value>
  120. <description>
  121. The ACL of who can submit applications with configured priority.
  122. For e.g, [user={name} group={name} max_priority={priority} default_priority={priority}]
  123. </description>
  124. </property>
  125. <property>
  126. <!-- default队列的application能够指定的最大超时时间 -->
  127. <!-- 如果application指定了超时时间,则提交到该队列的application能够指定的最大超时时间不能超过该值 -->
  128. <!-- 任务的超时时间设置:yarn application -appId <app_id> -updateLifetime <Timeout> -->
  129. <!-- 任务执行时间如果超过了指定的超时时间,将会被kill掉 -->
  130. <name>yarn.scheduler.capacity.root.default.maximum-application-lifetime
  131. </name>
  132. <value>-1</value>
  133. <description>
  134. Maximum lifetime of an application which is submitted to a queue
  135. in seconds. Any value less than or equal to zero will be considered as
  136. disabled.
  137. This will be a hard time limit for all applications in this
  138. queue. If positive value is configured then any application submitted
  139. to this queue will be killed after exceeds the configured lifetime.
  140. User can also specify lifetime per application basis in
  141. application submission context. But user lifetime will be
  142. overridden if it exceeds queue maximum lifetime. It is point-in-time
  143. configuration.
  144. Note : Configuring too low value will result in killing application
  145. sooner. This feature is applicable only for leaf queue.
  146. </description>
  147. </property>
  148. <property>
  149. <!-- 默认没有hive队列,需要自行添加 -->
  150. <name>yarn.scheduler.capacity.root.default.maximum-application-lifetime
  151. </name>
  152. <value>-1</value>
  153. <description>
  154. Maximum lifetime of an application which is submitted to a queue
  155. in seconds. Any value less than or equal to zero will be considered as
  156. disabled.
  157. This will be a hard time limit for all applications in this
  158. queue. If positive value is configured then any application submitted
  159. to this queue will be killed after exceeds the configured lifetime.
  160. User can also specify lifetime per application basis in
  161. application submission context. But user lifetime will be
  162. overridden if it exceeds queue maximum lifetime. It is point-in-time
  163. configuration.
  164. Note : Configuring too low value will result in killing application
  165. sooner. This feature is applicable only for leaf queue.
  166. </description>
  167. </property>
  168. <property>
  169. <!-- default队列,如果没有为application指定超时时间,则使用 default-application-lifetime 作为默认值 -->
  170. <name>yarn.scheduler.capacity.root.default.default-application-lifetime
  171. </name>
  172. <value>-1</value>
  173. <description>
  174. Default lifetime of an application which is submitted to a queue
  175. in seconds. Any value less than or equal to zero will be considered as
  176. disabled.
  177. If the user has not submitted application with lifetime value then this
  178. value will be taken. It is point-in-time configuration.
  179. Note : Default lifetime can't exceed maximum lifetime. This feature is
  180. applicable only for leaf queue.
  181. </description>
  182. </property>
  183. <property>
  184. <!-- 默认没有hive队列,需要自行添加 -->
  185. <name>yarn.scheduler.capacity.root.default.default-application-lifetime
  186. </name>
  187. <value>-1</value>
  188. <description>
  189. Default lifetime of an application which is submitted to a queue
  190. in seconds. Any value less than or equal to zero will be considered as
  191. disabled.
  192. If the user has not submitted application with lifetime value then this
  193. value will be taken. It is point-in-time configuration.
  194. Note : Default lifetime can't exceed maximum lifetime. This feature is
  195. applicable only for leaf queue.
  196. </description>
  197. </property>
  198. <!-- 后面的配置和容量调度器root没有关系,保持默认即可 -->


修改好配置文件后,分发到集群中其他节点。

如果此时Yarn集群正在启动着,可以执行刷新队列配置信息命令,不需要重启集群:

  1. # 刷新Yarn队列配置信息
  2. # yarn rmadmin不能刷新 yarn-site.xml。如果修改了 yarn-site.xml,只能重启Yarn集群
  3. yarn rmadmin -refreshQueues

启动wordcount程序,指定提交的队列:

  1. # 指定提交到hive队列
  2. # -D 运行时改变参数值
  3. hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.2.3.jar wordcount -D mapreduce.job.queuename=hive /input /output

如果运行的是自己编写的 java 程序,也可以通过configuration对象指定提交的队列:

  1. // 指定提交到hive队列
  2. configuration.set("mapreduce.job.queuename", "hive");

任务优先级配置

容量调度器支持任务优先级的配置,在资源紧张时,优先级高的任务将优先获取资源。

默认情况下,Yarn将所有任务的优先级限制为0,若想使用任务的优先级功能,必须开放该限制。

修改yarn-site.xml,增加参数:

  1. <property>
  2. <!-- 设置Yarn的任务优先级,默认值0 -->
  3. <!-- 设置5,表示我们可以有5个优先级:0/1/2/3/4/5,数字越大优先级越高 -->
  4. <name>yarn.cluster.max-application-priority</name>
  5. <value>5</value>
  6. </property>

分发到集群其他节点。

重启Yarn集群:

  1. sbin/stop-yarn.sh
  2. sbin/start-yarn.sh

当集群中资源不足出现排队时,可以通过调整任务的优先级达到优先执行的目的:

  1. # 在任务启动时就指定任务的优先级
  2. hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.2.3.jar wordcount -D mapreduce.job.priority=5 /input /output
  3. # 也可以通过命令修改正在执行的任务的优先级
  4. yarn application -appID <app_id> -updatePriority 5

公平调度器案例

需求:除了默认的default队列,再创建两个队列,分别是 testtengyer(用户所属组)。希望实现以下效果:若用户提交任务时指定队列,则任务提交到指定队列运行;若未指定队列,test用户提交的任务到 root.group.test 队列运行,tengyer用户提交的任务到 root.group.tengyer队列运行(group为用户所属组)。

公平调度器的配置涉及两个文件:一个是 yarn-site.xml,一个是公平调度器队列分配文件 fair-scheduler.xml(文件名可自定义)。

公平调度器在中大型公司中被广泛使用。

修改yarn-site.xml,进行以下配置:

  1. <property>
  2. <!-- 使用公平调度器 -->
  3. <name>yarn.resourcemanager.scheduler.class</name>
  4. <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
  5. </property>
  6. <property>
  7. <!-- 声明公平调度器队列分配的配置文件 -->
  8. <name>yarn.scheduler.fair.allocation.file</name>
  9. <value>/opt/module/hadoop-3.2.3/etc/hadoop/fair-scheduler.xml</value>
  10. </property>
  11. <property>
  12. <!-- 禁止队列间资源抢占 -->
  13. <name>yarn.scheduler.fair.preemption</name>
  14. <value>false</value>
  15. </property>

配置 fair-scheduler.xml

  1. <?xml version="1.0"?>
  2. <allocations>
  3. <!-- 单个队列中 Application Master占用资源的最大比例,取值 0-1,企业一般配置 0.1 -->
  4. <queueMaxAMShareDefault>0.5</queueMaxAMShareDefault>
  5. <!-- 单个队列最大资源的默认值 test tenger default -->
  6. <queueMaxResourcesDefault>4096mb,4vcores</queueMaxResourcesDefault>
  7. <!-- 增加一个队列test -->
  8. <queue name="test">
  9. <!-- 队列最小资源 -->
  10. <minResources>2048mb,2vcores</minResources>
  11. <!-- 队列最大资源 -->
  12. <maxResources>4096mb,4vcores</maxResources>
  13. <!-- 队列中最多同时运行的应用数,默认50,根据线程数配置 -->
  14. <maxRunningApps>4</maxRunningApps>
  15. <!-- 队列中 Application Master 占用资源的最大比例 -->
  16. <maxAMShare>0.5</maxAMShare>
  17. <!-- 该队列资源权重,默认值1.0 -->
  18. <weight>1.0</weight>
  19. <!-- 队列内部的资源分配策略 -->
  20. <schedulingPolicy>fair</schedulingPolicy>
  21. </queue>
  22. <!-- 增加一个队列tengyer -->
  23. <!-- 当type设置为parent时,它会成为父队列 -->
  24. <queue name="tengyer" type="parent">
  25. <!-- 队列最小资源 -->
  26. <minResources>2048mb,2vcores</minResources>
  27. <!-- 队列最大资源 -->
  28. <maxResources>4096mb,4vcores</maxResources>
  29. <!-- 队列中最多同时运行的应用数,默认50,根据线程数配置 -->
  30. <maxRunningApps>4</maxRunningApps>
  31. <!-- 队列中 Application Master, maxAMShare只能用于叶子队列,不能用于父队列。所以此处不能配置maxAMShare,否则ResourceMananger启动不了。 -->
  32. <!--<maxAMShare>0.5</maxAMShare>-->
  33. <!-- 该队列资源权重,默认值1.0 -->
  34. <weight>1.0</weight>
  35. <!-- 队列内部的资源分配策略 -->
  36. <schedulingPolicy>fair</schedulingPolicy>
  37. </queue>
  38. <!-- 任务队列分配策略,可配置多层规则,从第一个规则开始匹配,直到匹配成功 -->
  39. <queuePlacementPolicy>
  40. <!-- 任务队列分配策略,如果未指定提交队列,则继续匹配下一个规则;false表示:如果指定队列不存在,不允许自动创建 -->
  41. <rule name="specified" create="false" />
  42. <!-- 提交到 root.group.username 队列,若 root.group 不存在,不允许自动创建;若 root.group.user 不存在,允许自动创建 -->
  43. <rule name="nestedUserQueue" create="true">
  44. <rule name="primaryGroup" create="false" />
  45. </rule>
  46. <!-- 最后一个规则必须是reject或者default。reject表示如果前面的条件都不满足,则拒绝创建队列,提交失败。default表示把任务提交到default队列 -->
  47. <!-- 或者配置成默认: name="default" queue="指定一个默认队列" -->
  48. <rule name="reject" />
  49. </queuePlacementPolicy>
  50. </allocations>

将配置文件分发到集群其他节点服务器。

重启yarn集群。

提交任务时指定队列:

根据配置的分配策略,如果指定了队列,那么会到指定的队列中执行。但是如果指定的队列不存在,则不允许创建队列。

  1. <rule name="specified" create="false" />
  1. hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.2.3.jar wordcount -D mapreduce.job.queuename=root.test /input /output

根据前面配置的策略,如果不指定队列,则提交到对应用户名称的队列,即root.tengyer.tengyer队列(root.用户组.用户名):

我们声明了一个队列root.tengyertype="parent"。然后在分配策略中指定了:不允许创建primaryGrouproot.用户组父队列),但是允许创建nestedUserQueueroot.用户组.用户名队列),所以可以在root.tengyer父队列中创建出root.tengyer.tengyer队列。

  1. <rule name="nestedUserQueue" create="true">
  2. <rule name="primaryGroup" create="false" />
  3. </rule>
  1. hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.2.3.jar wordcount /input /output