分享

Hadoop3.0: YARN Resource自定义资源配置说明

pig2 2017-12-23 10:18:12 发表于 连载型 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 2 15974
本帖最后由 pig2 于 2017-12-23 15:13 编辑
问题导读

1.yarn默认情况下使用哪些资源?
2.Yarn如何实现扩展自定义资源?
3.自定义资源,可以在哪个配置文件中配置?
4.哪些配置可以在yarn-site.xml文件或则 resource-types.xml文件配置?
5.yarn有哪三种Containers?
6.三种Container如何配置请求的CPU,memory等值?





1.概述
yarn支持可扩展资源类型.所有节点、应用程序、队列,默认情况下Yarn使用 CPU和内存。资源定义可以扩展为任意的“countable”资源。一个countable 资源,container运行的时候,将会被暂用,完毕后将会释放。CPU 和(内存)memory都是 countable 资源。其它例子:包括GPU 资源和软件licenses.

2.配置
支持下面属性,详细如下:
resource-types.xml
配置属性
yarn.resource-types         额外资源列表,用逗号分隔.不包括: memory, memory-mb和vcores
yarn.resource-types.<resource>.units        指定资源类型的默认单位
yarn.resource-types.<resource>.minimum         指定资源类型的最小请求。
yarn.resource-types.<resource>.maximum         指定资源类型的最大请求。

node--resources.xml
配置属性
yarn.nodemanager.resource-type.<resource>          node manager指定可用资源的个数

注意:如果使用resource-types.xml和node-resources.xml文件,则需要将它们放在与yarn-site.xml相同的配置目录中

3.yarn资源模型
Resource Manager
resource manager【资源管理器】是tracke集群中哪些资源的最终仲裁者。它从XML配置文件加载定义资源。。例如定义新增加的CPU 和memory,下面属性应该被配置
[mw_shl_code=xml,true]<configuration>
  <property>
    <name>yarn.resource-types</name>
    <value>resource1,resource2</value>
    <description>
    The resources to be used for scheduling. Use resource-types.xml
    to specify details about the individual resource types.
    </description>
  </property>
</configuration>[/mw_shl_code]
有效的资源名称必须以字母开头,并且只能包含字母,数字和“。”,“_”或“ - ”中的任何一个。有效的资源名称也可以选择在名称空间后加一个斜杠。一个有效的名字空间由句点分隔的字母,数字和破折号组成。 例如,以下是有效的资源名称:
  • myresource
  • my_resource
  • My-Resource01
  • com.acme/myresource
以下是无效资源名的示例:
  • 10myresource【字母开头】
  • my resource【含有空格】
  • com/acme/myresource【没有命名空间】
  • $NS/myresource【字母开头】
  • -none-/myresource【字母开头】
以上个人标注上了错误的比较明显的原因。大家也可以找找其它方面的错误。
对于定义的每个新的资源类型,可以添加可选的单元属性来设置资源类型的默认单位。 有效值是:

单位名称
含义
p
pico
n
nano
u
micro
m
milli

default, i.e. no unit
k
kilo
M
mega
G
giga
T
tera
P
peta
Ki
binary kilo, i.e. 1024
Mi
binary mega, i.e. 1024^2
Gi
binary giga, i.e. 1024^3
Ti
binary tera, i.e. 1024^4
Pi
binary peta, i.e. 1024^5

属性必须命名为yarn.resource-types.<resource>.units。每个定义的资源也可以具有可选的最小和最大属性。属性必须命名为: yarn.resource-types.<resource>.minimum 和yarn.resource-types.<resource>.maximum.

yarn.resource-types属性和任何的unit, mimimum, 或则maximum属性,可以定义在yarn-site.xml文件或则 resource-types.xml文件。例如,以下内容可能出现在任一文件中:
[mw_shl_code=xml,true]<configuration>
  <property>
    <name>yarn.resource-types</name>
    <value>resource1, resource2</value>
  </property>

  <property>
    <name>yarn.resource-types.resource1.units</name>
    <value>G</value>
  </property>

  <property>
    <name>yarn.resource-types.resource2.minimum</name>
    <value>1</value>
  </property>

  <property>
    <name>yarn.resource-types.resource2.maximum</name>
    <value>1024</value>
  </property>
</configuration>[/mw_shl_code]

Node Manager
每个Node Manager独立定义该节点可用的资源。资源定义通过设置每个可用资源属性来完成。属性必须命名为 yarn.nodemanager.resource-type.<resource>或则放到 yarn-site.xml文件或则 node-resources.xml文件。该属性的值应该是该node提供的资源量。例子
[mw_shl_code=xml,true]<configuration>
<property>
   <name>yarn.nodemanager.resource-type.resource1</name>
   <value>5G</value>
</property>

<property>
   <name>yarn.nodemanager.resource-type.resource2</name>
   <value>2m</value>
</property>

</configuration>[/mw_shl_code]
请注意,用于这些资源的单位不需要与资源管理器【resource manager】所持有的定义相匹配。 如果单元不匹配,资源管理器将自动进行转换。


MapReduce使用资源
mapreduce从yarn请求三种不同类型的容器:application master容器, map容器,和reduce容器.对于每种容器类型,都有相应的一组属性可用于设置所请求的资源。在MapReduce中设置资源请求的属性有:

属性
描述
yarn.app.mapreduce.am.resource.mb
设置application master 容器请求的内存的值,以MB为单位。不在优先。使用yarn.app.mapreduce.am.resource.memory-mb代替,默认1536
yarn.app.mapreduce.am.resource.memory
设置application master 容器请求的内存的值,以MB为单位。不在优先。使用yarn.app.mapreduce.am.resource.memory-mb代替,默认1536
yarn.app.mapreduce.am.resource.memory-mb
设置application master 容器请求的内存的值,以MB为单位。默认1536
yarn.app.mapreduce.am.resource.cpu-vcores
设置application master容器请求 CPU的值,不在优先,使用yarn.app.mapreduce.am.resource.vcores代替,默认为1
yarn.app.mapreduce.am.resource.vcores
设置application master容器请求 CPU的值,默认为1

yarn.app.mapreduce.am.resource.<resource>
设置application master容器请求的<resource>的数量的值。
Sets the quantity requested of <resource> for the application master container to the value. 如果没有指定unit ,则假定资源的默认unit 。见上面关于unit 的部分。
mapreduce.map.memory.mb
设置所有map任务的Container的请求memory,以MB为单位。不在优先。使用mapreduce.map.resource.memory-mb代替,默认值1024
mapreduce.map.resource.memory
设置所有map任务的Container的请求memory,以MB为单位。不在优先。使用mapreduce.map.resource.memory-mb代替,默认值1024
mapreduce.map.resource.memory-mb
设置所有map任务的Container的请求memory,以MB为单位。默认值1024

mapreduce.map.cpu.vcores
设置所有map任务Container请求的CPU。不在优先。使用mapreduce.map.resource.vcores代替。默认为1。
mapreduce.map.resource.vcores
设置所有map任务Container请求的CPU的值,默认为1

mapreduce.map.resource.<resource>
设置所有map任务Container请求的<resource>数量的值。如果没有设置unit。使用resource的默认unit。请参阅上面的units 部分。
mapreduce.reduce.memory.mb
设置所有reduce任务的Containers请求的memory的值,以MB为单位。不在优先。使用mapreduce.reduce.resource.memory-mb代替,默认为1024

mapreduce.reduce.resource.memory
设置所有reduce任务Containers请求的memory值,以MB为单位。不在优先。使用mapreduce.reduce.resource.memory-mb代替,默认1024
mapreduce.reduce.resource.memory-mb
设置所有reduce任务Containers请求的memory的值,以MB为单位。默认1024

mapreduce.reduce.cpu.vcores
设置所有reduce任务Containers请求的CPU的值。不在优先。使用mapreduce.reduce.resource.vcores代替,默认为1
mapreduce.reduce.resource.vcores
设置所有reduce任务Containers的请求的CPU的值,默认为1

mapreduce.reduce.resource.<resource>
设置所有reduce任务请求<resource>的数量的值。如果没有unit 指定,使用resource默认unit。请参阅上面的units 部分。

注意,这些资源请求可能会被YARN修改,以满足配置的minimum 和maximum 资源值,或者是配置增量的倍数。 请参阅yarn调度配置属性 yarn.scheduler.maximum-allocation-mb, yarn.scheduler.minimum-allocation-mb, yarn.scheduler.increment-allocation-mb, yarn.scheduler.maximum-allocation-vcores, yarn.scheduler.minimum-allocation-vcores, and yarn.scheduler.increment-allocation-vcores。







本帖被以下淘专辑推荐:

已有(2)人评论

跳转到指定楼层
pig2 发表于 2017-12-23 15:16:36
hadoop3.1资源类型支持比如: disk(YARN-2139), network(YARN-2140), and HDFS 带宽(YARN-2681).
链接:
磁盘(disk)
https://issues.apache.org/jira/browse/YARN-2139
网络(network)
https://issues.apache.org/jira/browse/YARN-2140
HDFS 带宽
https://issues.apache.org/jira/browse/YARN-2681
回复

使用道具 举报

aaronping 发表于 2017-12-24 11:20:46
多谢楼主分享,自己用时根据实际环境条件调整。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条