YARN的队列配置

2023-12-13 16:45:30

1.6. YARN的队列配置

YARN默认采用的调度器是容量调度,且默认只有一个任务队列。该调度器内单个队列的调度策略为FIFO,因此在单个队列中的任务并行度为1。那么就会出现单个任务阻塞的情况,如果随着业务的增长,充分的利用到集群的使用率,我们就需要手动的配置多条任务队列。

1.6.1. 配置任务队列

默认YARN只有一个default任务队列,现在我们添加一个small的任务队列。

修改配置文件: $HADOOP_HOME/etc/hadoop/capacity-scheduler.xml [root@qianfeng01 hadoop-3.3.1]# rm -rf /usr/local/hadoop-3.3.1/etc/hadoop/capacity-scheduler.xml [root@qianfeng01 hadoop-3.3.1]# vi /usr/local/hadoop-3.3.1/etc/hadoop/capacity-scheduler.xml

<configuration>
 ? ?<!-- 不需要修改 -->
 ? ?<!-- 容量调度器中最多容纳多少个Job -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.maximum-applications</name>
 ? ? ? ?<value>10000</value>
 ? ? ? ?<description>
 ? ? ? ? ?  Maximum number of applications that can be pending and running.
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 不需要修改 -->
 ? ?<!-- MRAppMaster进程所占的资源可以占用队列总资源的百分比,可以通过修改这个参数来限制队列中提交Job的数量 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.maximum-am-resource-percent</name>
 ? ? ? ?<value>0.1</value>
 ? ? ? ?<description>
 ? ? ? ? ?  Maximum percent of resources in the cluster which can be used to run
 ? ? ? ? ?  application masters i.e. controls number of concurrent running
 ? ? ? ? ?  applications.
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 不需要修改 -->
 ? ?<!-- 为Job分配资源的时候,使用什么策略 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.resource-calculator</name>
 ? ? ? ?<value>org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The ResourceCalculator implementation to be used to compare
 ? ? ? ? ?  Resources in the scheduler.
 ? ? ? ? ?  The default i.e. DefaultResourceCalculator only uses Memory while
 ? ? ? ? ?  DominantResourceCalculator uses dominant-resource to compare
 ? ? ? ? ?  multi-dimensional resources such as Memory, CPU etc.
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 修改!!! -->
 ? ?<!-- 调度器中有什么队列,我们添加一个small队列 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.queues</name>
 ? ? ? ?<value>default,small</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The queues at the this level (root is the root queue).
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 修改!!! -->
 ? ?<!-- 配置default队列的容量百分比 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.default.capacity</name>
 ? ? ? ?<value>70</value>
 ? ? ? ?<description>Default queue target capacity.</description>
 ? ?</property>
?
 ? ?<!-- 新增!!! -->
 ? ?<!-- 新增small队列的容量百分比 -->
 ? ?<!-- 所有的队列容量百分比和需要是100 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.small.capacity</name>
 ? ? ? ?<value>30</value>
 ? ? ? ?<description>Default queue target capacity.</description>
 ? ?</property>
?
 ? ?<!-- 不需要修改 -->
 ? ?<!-- default队列用户能使用的容量最大百分比 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.default.user-limit-factor</name>
 ? ? ? ?<value>1</value>
 ? ? ? ?<description>
 ? ? ? ? ?  Default queue user limit a percentage from 0.0 to 1.0.
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 添加!!! -->
 ? ?<!-- small队列用户能使用的容量最大百分比 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.small.user-limit-factor</name>
 ? ? ? ?<value>1</value>
 ? ? ? ?<description>
 ? ? ? ? ?  Default queue user limit a percentage from 0.0 to 1.0.
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 不需要修改 -->
 ? ?<!-- default队列能使用的容量最大百分比 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.default.maximum-capacity</name>
 ? ? ? ?<value>100</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The maximum capacity of the default queue. 
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 添加!!! -->
 ? ?<!-- small队列能使用的容量最大百分比 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.small.maximum-capacity</name>
 ? ? ? ?<value>100</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The maximum capacity of the default queue. 
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 不需要修改 -->
 ? ?<!-- default队列的状态 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.default.state</name>
 ? ? ? ?<value>RUNNING</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The state of the default queue. State can be one of RUNNING or STOPPED.
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 添加!!! -->
 ? ?<!-- small队列的状态 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.small.state</name>
 ? ? ? ?<value>RUNNING</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The state of the default queue. State can be one of RUNNING or STOPPED.
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 不需要修改 -->
 ? ?<!-- 限制向队列提交的用户-->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.default.acl_submit_applications</name>
 ? ? ? ?<value>*</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The ACL of who can submit jobs to the default queue.
 ? ? ? ?</description>
 ? ?</property>
 ? ?<!-- 添加!!! -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.small.acl_submit_applications</name>
 ? ? ? ?<value>*</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The ACL of who can submit jobs to the default queue.
 ? ? ? ?</description>
 ? ?</property>
?
 ? ?<!-- 不需要修改 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.default.acl_administer_queue</name>
 ? ? ? ?<value>*</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The ACL of who can administer jobs on the default queue.
 ? ? ? ?</description>
 ? ?</property>
 ? ?<!-- 添加!!! -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.root.small.acl_administer_queue</name>
 ? ? ? ?<value>*</value>
 ? ? ? ?<description>
 ? ? ? ? ?  The ACL of who can administer jobs on the default queue.
 ? ? ? ?</description>
 ? ?</property>
?
?
 ? ?<!-- 不需要修改 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.node-locality-delay</name>
 ? ? ? ?<value>40</value>
 ? ? ? ?<description>
 ? ? ? ? ?  Number of missed scheduling opportunities after which the CapacityScheduler 
 ? ? ? ? ?  attempts to schedule rack-local containers. 
 ? ? ? ? ?  Typically this should be set to number of nodes in the cluster, By default is setting 
 ? ? ? ? ?  approximately number of nodes in one rack which is 40.
 ? ? ? ?</description>
 ? ?</property>
 ? ?<!-- 不需要修改 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.queue-mappings</name>
 ? ? ? ?<value></value>
 ? ? ? ?<description>
 ? ? ? ? ?  A list of mappings that will be used to assign jobs to queues
 ? ? ? ? ?  The syntax for this list is [u|g]:[name]:[queue_name][,next mapping]*
 ? ? ? ? ?  Typically this list will be used to map users to queues,
 ? ? ? ? ?  for example, u:%user:%user maps all users to queues with the same name
 ? ? ? ? ?  as the user.
 ? ? ? ?</description>
 ? ?</property>
 ? ?<!-- 不需要修改 -->
 ? ?<property>
 ? ? ? ?<name>yarn.scheduler.capacity.queue-mappings-override.enable</name>
 ? ? ? ?<value>false</value>
 ? ? ? ?<description>
 ? ? ? ? ?  If a queue mapping is present, will it override the value specified
 ? ? ? ? ?  by the user? This can be used by administrators to place jobs in queues
 ? ? ? ? ?  that are different than the one specified by the user.
 ? ? ? ? ?  The default is false.
 ? ? ? ?</description>
 ? ?</property>
</configuration>
1.6.2. 分发配置到各个节点
[root@qianfeng01 hadoop-3.3.1]# scp /usr/local/hadoop-3.3.1/etc/hadoop/capacity-scheduler.xml qianfeng02:/usr/local/hadoop-3.3.1/etc/hadoop/
[root@qianfeng01 hadoop-3.3.1]# scp /usr/local/hadoop-3.3.1/etc/hadoop/capacity-scheduler.xml qianfeng03:/usr/local/hadoop-3.3.1/etc/hadoop/
?
# 重启集群
[root@qianfeng01 hadoop]# stop-yarn.sh
[root@qianfeng01 hadoop]# start-yarn.sh
1.6.3. 提交任务
# 提交Job到default队列,其中的-Dmapreduce.job.queuename可以不指定,因为现在默认向default队列提交Job
[root@qianfeng01 ~]# hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.3.1.jar wordcount -Dmapreduce.job.queuename=default /input /output1
?
# 提交Job到small队列
[root@qianfeng01 ~]# hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.3.1.jar wordcount -Dmapreduce.job.queuename=small /input /output2
1.6.4. 查看任务

http://192.168.10.101:8088/cluster/scheduler

1.6.5. 默认队列设置

YARN默认将任务提交到default队列,我们如果需要提交到其他的队列中,可以使用-Dmapreduce.job.queuename指定提交的队列。也可以设置默认的任务提交队列。

例如: Hive的底层会把HQL语句翻译成MapReduce的程序执行,我们可以创建一个hive队列,将这个队列的容量设置的大一些。我们可以设置默认将任务提交到这个队列中。如果需要往其他的队列中提交任务的话,可以再使用-Dmapreduce.job.queuename去提交了。

  • 临时生效

set mapreduce.job.queuename=small;
set mapreduce.job.priority=HIGH;
  • 永久生效

<!--配置hive默认的提交队列-->
<property>
 ? ?<name>mapreduce.job.queuename</name>
 ? ?<value>small</value>
</property>

Guff_hys_python数据结构,大数据开发学习,python实训项目-CSDN博客

文章来源:https://blog.csdn.net/HYSliuliuliu/article/details/134947877
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。