- Hadoop 配置多队列的容量调度器及优先级配置
- 1 配置多队列的容量调度器
- 1.1 在 capacity-scheduler.xml 中配置如下
- 1.2 分发配置文件,刷新队列
- 1.3 向Hive队列提交任务
- 2 任务优先级配置
- 2.1 yarn-site.xml文件,增加以下参数
- 2.2 将yarn-site.xml集群其他节点,重启Yarn
- 2.3 提交任务设置优先级
- 2.4 修改正在执行的任务的优先级
版本: hadoop-3.1.3
需求 1:default 队列占总内存的 40%,最大资源容量占总资源 60%,hive 队列占总内存的 60%,最大资源容量占总资源 80%。
需求 2:配置队列优先级
注意:可能因为中文原因,yarn启动失败,可将中文注释去掉重启
- 修改
yarn.scheduler.capacity.root.queues default,hive The queues at the this level (root is the root queue). yarn.scheduler.capacity.root.default.capacity 40 yarn.scheduler.capacity.root.default.maximum-capacity 60
- 为新加队列添加必要属性
1.2 分发配置文件,刷新队列yarn.scheduler.capacity.root.hive.capacity 60 yarn.scheduler.capacity.root.hive.user-limit-factor 1 yarn.scheduler.capacity.root.hive.maximum-capacity 80 yarn.scheduler.capacity.root.hive.state RUNNING yarn.scheduler.capacity.root.hive.acl_submit_applications * yarn.scheduler.capacity.root.hive.acl_administer_queue * yarn.scheduler.capacity.root.hive.acl_application_max_priority * yarn.scheduler.capacity.root.hive.maximum-applicationlifetime -1 yarn.scheduler.capacity.root.hive.default-applicationlifetime -1
yarn rmadmin -refreshQueues1.3 向Hive队列提交任务
- 指令方式
# -D mapreduce.job.queuename=hive 表示提交到hive队列中 [develop@hadoop100 hadoop-3.1.3]$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar wordcount -D mapreduce.job.queuename=hive /input /output
- 代码指定队列(伪代码)
Configuration conf = new Configuration();
// 设置提交指定队列
conf.set("mapreduce.job.queuename","hive");
//1. 获取一个Job实例
Job job = Job.getInstance(conf);
.......
//6. 提交Job boolean b = job.waitForCompletion(true);
System.exit(b ? 0 : 1);
2 任务优先级配置
容量调度器,支持任务优先级的配置,在资源紧张时,优先级高的任务将优先获取资源。默认情况,Yarn将所有任务的优先级限制为0,若想使用任务的优先级功能,须开放该限制。
2.1 yarn-site.xml文件,增加以下参数2.2 将yarn-site.xml集群其他节点,重启Yarn 2.3 提交任务设置优先级yarn.cluster.max-application-priority 5
# -D mapreduce.job.priority=5 设置有优先为5 hadoop jar /opt/module/hadoop3.1.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar pi -D mapreduce.job.priority=5 5 20000002.4 修改正在执行的任务的优先级
# yarn application -appID -updatePriority 优先级 yarn application -appID application_1611133087930_0009 -updatePriority 5



