需求
公司里有两个部门,一个叫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:
mapred.jobtracker.taskScheduler
org.apache.hadoop.mapred.CapacityTaskScheduler
mapred.queue.names
default,hive,pig
在capacity-scheduler.xml文件中填写如下内容:
mapred.capacity-scheduler.queue.hive.capacity
40
Percentage of the number of slots in the cluster that are
to be available for jobs in this queue.
mapred.capacity-scheduler.queue.hive.maximum-capacity
-1
mapred.capacity-scheduler.queue.hive.supports-priority
true
mapred.capacity-scheduler.queue.hive.minimum-user-limit-percent
100
mapred.capacity-scheduler.queue.hive.user-limit-factor
3
mapred.capacity-scheduler.queue.hive.maximum-initialized-active-tasks
200000
mapred.capacity-scheduler.queue.hive.maximum-initialized-active-tasks-per-user
100000
mapred.capacity-scheduler.queue.hive.init-accept-jobs-factor
10
mapred.capacity-scheduler.queue.pig.capacity
30
mapred.capacity-scheduler.queue.pig.maximum-capacity
-1
mapred.capacity-scheduler.queue.pig.supports-priority
true
If true, priorities of jobs will be taken into
account in scheduling decisions.
mapred.capacity-scheduler.queue.pig.minimum-user-limit-percent
100
mapred.capacity-scheduler.queue.pig.user-limit-factor
4
The multiple of the queue capacity which can be configured to
allow a single user to acquire more slots.
mapred.capacity-scheduler.queue.pig.maximum-initialized-active-tasks
200000
mapred.capacity-scheduler.queue.pig.maximum-initialized-active-tasks-per-user
100000
mapred.capacity-scheduler.queue.pig.init-accept-jobs-factor
10
mapred.capacity-scheduler.queue.default.capacity
30
mapred.capacity-scheduler.queue.default.maximum-capacity
-1
mapred.capacity-scheduler.queue.default.supports-priority
true
mapred.capacity-scheduler.queue.default.minimum-user-limit-percent
100
mapred.capacity-scheduler.queue.default.user-limit-factor
4
mapred.capacity-scheduler.queue.default.maximum-initialized-active-tasks
200000
mapred.capacity-scheduler.queue.default.maximum-initialized-active-tasks-per-user
100000
mapred.capacity-scheduler.queue.default.init-accept-jobs-factor
10
这里配置了三个队列,分别是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管理控制台可以看到结果。
注意:如果配置没有同步到所有的节点,一些队列会无法启用。
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com