yarn
前言:
基于标签的调度解决的核心需求是实现部分资源的完全隔离,以及由此基础之上的各个资源池之间的资源互助,最终达到隔离并且弹性的计算形态。
该特性开发现状:
最新版本2.8.x:
1.不支持标签表达式,如:&&,|,*
2.资源共享方式不实用,如:2.8.x的模式是labeled资源池向default资源池共享资源。
3.user-limit限制不可用,如:在队列中用户所能使用的资源不受当前活跃用户数限制。
4.BUG,如:队列可同时运行am限制计算错误,队列总资源显示错误
如何配置:
-
在hdfs上创建用于保存label相关数据的目录(相关数据后期有Patch改为用zk存储)。
-
hdfs dfs -mkdir /xxx/xxx/node-label/
-
hdfs dfs -chown yarn:yarn /xxx/xxx/node-label/
-
hdfs dfs -chmod 700 /xxx/xxx/node-label/
-
-
在yarn-site.xml文件中配置:
yarn.node-labels.enabled=true
yarn.node-labels.fs-store.root-dir=/xxx/xxx/node-label
yarn.resourcemanager.scheduler.class=org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler
-
配置capacity-scheduler.xml(后面详解)
如何管理标签:
添加标签:
yarn rmadmin -addToClusterNodeLabels "<label1>(exclusive=<true|false>),<label2>(exclusive=<true|false>)"
说明:exclusive是指该标签管理的资源是否允许分享资源给default分区的任务。
查看添加的标签:
yarn cluster --list-node-labels
给机器添加标签:
yarn rmadmin -replaceLabelsOnNode "<node1>:<port>=<label1> <node2>:<port>=<label2>"
说明:1.node1处必须填写域名。2.如果“=label1“处为空,即表示重设机器标签为空。3.port处为空,即表示设置该机器上所有nm的标签。
删除标签:
yarn rmadmin -removeFromClusterNodeLabels "x","y"
配置capacity-scheduler.xml:
<property> <name>yarn.scheduler.capacity.root.queues</name> <value>a,b</value> </property> 说明:集群有多少队列 <property> <name>yarn.scheduler.capacity.root.accessible-node-labels.x.capacity</name> <value> 100 </value>
</property> 说明:集群可用的X标签资源量 <property> <name>yarn.scheduler.capacity.root.accessible-node-labels.y.capacity</name> <value> 100 </value>
</property> 说明:同理 注(以下不用配置,对于 default 分区的资源,root队列默认是可以访问的):
/** *<property> * <name>yarn.scheduler.capacity.root.capacity</name> * <value>100</value> *</property> */ <!-- configuration of queue-a --> <property> <name>yarn.scheduler.capacity.root.a.accessible-node-labels</name> <value>x,y</value> </property> 说明:配置队列a能访问的标签,如果设置队列只能访问 default 分区资源则值留空格“ ”,如果值为 null 则队列访问权限继承父队列
<property> <name>yarn.scheduler.capacity.root.a.capacity</name> <value> 40 </value>
</property> 说明:配置队列a能访问的 default 分区的资源量
<property> <name>yarn.scheduler.capacity.root.a.accessible-node-labels.x.capacity</name> <value> 100 </value>
</property> 说明:同理 <property> <name>yarn.scheduler.capacity.root.a.accessible-node-labels.y.capacity</name> <value> 50 </value>
</property> 说明:同理 <!-- configuration of queue-b --> 说明:队列b的配置同理 <property> <name>yarn.scheduler.capacity.root.b.accessible-node-labels</name> <value>y</value> </property> <property> <name>yarn.scheduler.capacity.root.b.capacity</name> <value> 60 </value>
</property> <property> <name>yarn.scheduler.capacity.root.b.accessible-node-labels.y.capacity</name> <value> 50 </value>
</property> 必须设置每个队列的默认提交标签(重要)如: <property> <name>yarn.scheduler.capacity.root.a. default -node-label-expression</name>
<value>x</value> </property> <property> <name>yarn.scheduler.capacity.root.b.b1. default -node-label-expression</name>
<value> </value> </property> 说明:如果值为“ ”则默认提交到 default 分区,不能为“”相当于没设,不能为*,&&,|等,不支持表达式
|
如何使用Node-label:
在Yarn中一共有4种方式设置Container的运行标签:
-
配置队列的默认标签(见上文配置)
-
ApplicationSubmissionContext.setNodeLabelExpression();
说明:设置作业所有的container运行的标签。 -
ApplicationSubmissionContext.setAMContainerResourceRequest().setNodeLabelExpression()
说明:设置AMContainer的运行标签 -
ResourceRequest.setNodeLabelExpression()
说明:设置最终向Capacityscheduler发送的RR的标签
说明:
以上方式的优先级依次加强。
具体以下表的形式(所有方式使用首字母缩写):
|
Queue default Label |
ASC.setNLE() |
ASC.setACRR().setNLE() |
RR.setNLE() |
---|---|---|---|---|
Queue default Label | 覆盖 | 被覆盖 | 被覆盖 | 被覆盖 |
ASC.setNLE() | 覆盖 | 覆盖 | 被覆盖 | 被覆盖 |
ASC.setACRR().setNLE() | 覆盖 | 覆盖 | 覆盖 | 被覆盖 |
RR.setNLE() | 覆盖 | 覆盖 | 覆盖 | 覆盖 |
资源模式:
-
非共享模式
-
说明:首先作业使用资源的原则是,提交时指定了标签则在对应标签运行,如果没有指定标签,则在空白标签运行。
在非共享模式下,提交到空白标签里的作业如果需要资源,即使标签A,B中有剩余资源,也不能被使用。 -
共享模式
-
说明:在上文情况下,空白标签的作业可以使用标签A,B中的资源,当标签A,B中再次需要资源时,会抢占回被共享的那部分。
典型应用场景:
参考资料:
-
http://pivotalhd.docs.pivotal.io/docs/yarn-resource-management.html
-
https://hadoop.apache.org/docs/stable/hadoop-yarn/hadoop-yarn-site/NodeLabel.html
-
http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/CapacityScheduler.html
-
https://wangda.live/2016/04/16/suggestions-about-how-to-better-use-yarn-node-label/