调度器的使用
来源:互联网 发布:修改歌曲信息软件 编辑:程序博客网 时间:2024/05/20 14:23
假如公司里有两个部门,一个叫hive,一个叫pig,这两个部门都需要使用公司里的hadoop集群。于是问题来了,因为hadoop默认是FIFO调度的,谁先提交任务,谁先被处理,于是hive部门很担心pig这个部门提交一个耗时的任务,影响了hive的业务,hive希望可以和pig在高峰期时,平均使用整个集群的计算容量,互不影响。
思路
hadoop的默认调度器是FIFO,但是也有计算容量调度器,这个调度器可以解决上述问题。可以在hadoop里配置三个队列,一个是default,一个是hive,一个是pig。他们的计算容量分别是30%,40%,30%.这样hive和pig这两个部门,分为使用hive和pig两个队列,其中default作为其他部门或者临时使用。但是,如果hive部门和pig部门又希望,在平常时,没有人用集群的时候,hive或者部门可以使用100%的计算容量。
解决方法
修改hadoop的配置文件mapred-site.xml:
<property> <name>mapred.jobtracker.taskScheduler</name> <value>org.apache.hadoop.mapred.CapacityTaskScheduler</value> </property> <property> <name>mapred.queue.names</name> <value>default,hive,pig</value> </property>
在capacity-scheduler.xml文件中填写如下内容:
<property> <name>mapred.capacity-scheduler.queue.hive.capacity</name> <value>40</value> <description>Percentage of the number of slots in the cluster that are to be available for jobs in this queue. </description> </property> <property> <name>mapred.capacity-scheduler.queue.hive.maximum-capacity</name> <value>-1</value> <description> </description> </property> <property> <name>mapred.capacity-scheduler.queue.hive.supports-priority</name> <value>true</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.hive.minimum-user-limit-percent</name> <value>100</value> <description> </description> </property> <property> <name>mapred.capacity-scheduler.queue.hive.user-limit-factor</name> <value>3</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.hive.maximum-initialized-active-tasks</name> <value>200000</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.hive.maximum-initialized-active-tasks-per-user</name> <value>100000</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.hive.init-accept-jobs-factor</name> <value>10</value> <description></description> </property> <!-- pig --><property> <name>mapred.capacity-scheduler.queue.pig.capacity</name> <value>30</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.pig.maximum-capacity</name> <value>-1</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.pig.supports-priority</name> <value>true</value> <description>If true, priorities of jobs will be taken into account in scheduling decisions. </description> </property> <property> <name>mapred.capacity-scheduler.queue.pig.minimum-user-limit-percent</name> <value>100</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.pig.user-limit-factor</name> <value>4</value> <description>The multiple of the queue capacity which can be configured to allow a single user to acquire more slots. </description> </property> <property> <name>mapred.capacity-scheduler.queue.pig.maximum-initialized-active-tasks</name> <value>200000</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.pig.maximum-initialized-active-tasks-per-user</name> <value>100000</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.pig.init-accept-jobs-factor</name> <value>10</value> <description></description> </property><!-- default --> <property> <name>mapred.capacity-scheduler.queue.default.capacity</name> <value>30</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.default.maximum-capacity</name> <value>-1</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.default.supports-priority</name> <value>true</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.default.minimum-user-limit-percent</name> <value>100</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.default.user-limit-factor</name> <value>4</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.default.maximum-initialized-active-tasks</name> <value>200000</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.default.maximum-initialized-active-tasks-per-user</name> <value>100000</value> <description></description> </property> <property> <name>mapred.capacity-scheduler.queue.default.init-accept-jobs-factor</name> <value>10</value> <description></description> </property>
这里配置了三个队列,分别是hive,pig,default,hive的容量是40%,由属性mapred.capacity-scheduler.queue.hive.capacity决定,其他队列的容量同理可得。
需要配置hive,pig,default可以抢占整个集群的资源,由属性mapred.capacity-scheduler.queue.hive.user-limit-factor绝对,hive队列这个值是3,所以用户可以使用的资源限量是40% * 3 =120%,所有有效计算容量是集群的100%.其他队列的最大集群计算容量同理可得。
如何使用该队列
mapreduce:在Job的代码中,设置Job属于的队列,例如hive:
conf.setQueueName("hive");
hive:在执行hive任务时,设置hive属于的队列,例如pig:
set mapred.job.queue.name=pig;
动态更新集群队列和容量
生产环境中,队列及其容量的修改在现实中是不可避免的,而每次修改,需要重启集群,这个代价很高,如果修改队列及其容量的配置不重启呢:
1.在主节点上根据具体需求,修改好mapred-site.xml和capacity-scheduler.xml
2.把配置同步到所有节点上
3.使用hadoop用户执行命令:hadoop mradmin -refreshQueues
这样就可以动态修改集群的队列及其容量配置,不需要重启了,刷新mapreduce的web管理控制台可以看到结果。
注意:如果配置没有同步到所有的节点,一些队列会无法启用。
- 调度器的使用
- Quartz调度器的使用
- spring 调度器的使用
- 定时任务调度器Quartz的使用
- Quartz调度器的使用001
- 任务调度器quartz的使用
- Spring中Quartz调度器的使用
- MySQL的事件调度器使用介绍
- Spring中Quartz调度器的使用
- Spring中Quartz调度器的使用
- Spring任务调度器Task的使用
- Spring中Quartz调度器的使用
- Spring中Quartz调度器的使用
- cocos3.10 Lua调度器的使用
- 使用Quartz调度器
- 使用Quartz调度器
- spring任务调度的使用
- oracle调度程序的使用
- 发求职信
- HDU 1046 Gridland
- 运行python时报错:Non-ASCII character '\xe5' in file问题解决
- 通过反射读取配置文件,来打印图形
- 黑马程序员------[C]字符串操作
- 调度器的使用
- 邻接表求有向图各顶点的入度和出度 (图论基础)
- hdu 3635 并查集
- AFNetWorking2.0 post 出现code=-1016错误怎么解决?
- 公司学习----JS获取URL传过来的值
- UVa 216 网络连线
- 3个收缩/展开/折叠的js代码
- Oracle判断是否闰年
- 异常处理与MiniDump详解(4) MiniDump