hadoop3.x yarn 调度策略:Fair Scheduler(公平调度)仅提交到默认队列配置(废弃) 作者:马育民 • 2022-01-05 21:58 • 阅读:10156 # 说明 提交任务时,如果不指定队列,提交到默认队列中,即:`root.default` 队列 # 修改yarn-site.xml配置 登录 `hadoop2` 修改 `yarn-site.xml` 文件: ``` vim /program/hadoop-3.0.3/etc/hadoop/yarn-site.xml ``` 增加下面内容: ### 指定公平调度方式 ``` yarn.resourcemanager.scheduler.class org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler ``` ### 开启抢占 ``` yarn.scheduler.fair.preemption true yarn.scheduler.fair.preemption.cluster-utilization-threshold 0.8f ``` ### 关键 ``` yarn.scheduler.fair.user-as-default-queue false ``` **解释:** - 默认true,提交任务未指定队列时,默认是将当前linux登录用户名作为队列名。这个配置就实现了根据用户名自动分配资源池 - 设置成false,当任务中未指定资源池的时候,将使用默认的队列,即:`root.default`,可在 fair-scheduler.xml 中配置默认队列 # 同步 同步到 hadoop1: ``` rsync -av /program/hadoop-3.0.3/etc/hadoop/* root@hadoop1:/program/hadoop-3.0.3/etc/hadoop/ ``` 同步到 hadoop3: ``` rsync -av /program/hadoop-3.0.3/etc/hadoop/* root@hadoop3:/program/hadoop-3.0.3/etc/hadoop/ ``` # 重启 yarn 登录 `hadoop2`,执行下面命令关闭 yarn: ``` stop-yarn.sh ``` ``` start-yarn.sh ``` # 访问 web 访问:http://hadoop2:8088/ ,查看队列,显示界面如下: [![](https://www.malaoshi.top/upload/pic/hadoop/Snipaste_2022-01-05_16-22-07.png)](https://www.malaoshi.top/upload/pic/hadoop/Snipaste_2022-01-05_16-22-07.png) 默认有 队列 `root.default` # 测试 **同时** 在 hadoop1、hadoop3执行下面命令 ``` hadoop jar ${HADOOP_HOME}/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.0.3.jar wordcount /test2/data.txt /result010519 ``` ``` hadoop jar ${HADOOP_HOME}/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.0.3.jar wordcount /test2/data.txt /result010518 ``` ### web查看任务 如下图,会发现多个任务同时执行 [![](https://www.malaoshi.top/upload/pic/hadoop/Snipaste_2022-01-05_16-25-38.png)](https://www.malaoshi.top/upload/pic/hadoop/Snipaste_2022-01-05_16-25-38.png) ### web查看队列 [![](https://www.malaoshi.top/upload/pic/hadoop/Snipaste_2022-01-05_22-12-21.png)](https://www.malaoshi.top/upload/pic/hadoop/Snipaste_2022-01-05_22-12-21.png) 提交到 `root.default` 队列中 原文出处:http://malaoshi.top/show_1IX2XTpNsc4w.html