Fanr

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

概述

YARN支持可扩展资源模块,默认YARN会跟着所有node,应用和队列中的内存和cpu,但是资源只能扩展可计数的资源,比如cpu ,内存,但是GPU和软件许可是不行的。

配置

yarn-site.xml

属性
yarn.resourcemanager.resource-profiles.enabled 是否启动资源配置

resource-types.xml

属性
yarn.resource-types 资源类型,逗号分割
yarn.resource-types..units 指定资源的单位
yarn.resource-types..minimum-allocation 特定资源最小请求数
yarn.resource-types..maximum-allocation 特定资源最大请求数

node-resource.xml

属性
yarn.nodemanager.resource-type. 特定可用资源的在node managner中的计数
YARN资源模型
资源管理器

资源管理器是最后的仲裁者什么资源被跟踪。资源管理器通过XML配置文件加载资源。如:


<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>

可用资源名必须以字母开头,可以包含字母,数字,还有‘.’, ‘_’, or ‘-’。名字也可以带斜杠。

单位
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
resouce-type.xml配置如下:

<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-allocation</name>
    <value>1</value>
  </property>

  <property>
    <name>yarn.resource-types.resource2.maximum-allocation</name>
    <value>1024</value>
  </property>
</configuration>
Node Manager

每个node管理,定义的资源对该node定义。资源定义通过对每个资源的属性定义。属性必须通过
 yarn.nodemanager.resource-type. 设置返回给在yarn-site.xml或者noderesources.xml。属性的值由node提供:

<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>

注意,这里的单位定义可以不与resource manager定义匹配。如果单位不匹配,resource manager会自动转移。

MapReduce的资源使用

MapReduce请求3个不同类型的YARN容器:application master容器,map容器和reduce容器。对每个容器类型,有相关的属性设置,可以用来设置资源请求。
MapReduce设置属性:

属性
yarn.app.mapreduce.am.resource.mb 不在使用,使用 第三个
yarn.app.mapreduce.am.resource.memory 不在使用使用第三个
yarn.app.mapreduce.am.resource.memory-mb 设置AM容器的内存请求
yarn.app.mapreduce.am.resource.cpu-vcores 不在使用,使用下面一条
yarn.app.mapreduce.am.resource.vcores 设置AM容器的CPU请求
yarn.app.mapreduce.am.resource. AM容器请求的的量
mapreduce.map.memory.mb 不在使用
mapreduce.map.resource.memory 不在使用
mapreduce.map.resource.memory-mb 所有的map任务容器的内存请求量
mapreduce.map.cpu.vcores 不在使用
mapreduce.map.resource.vcores 所有的map任务容器cpu请求
mapreduce.map.resource. 所有的map任务容器的请求量
mapreduce.reduce.memory.mb 不在使用
mapreduce.reduce.resource.memory 不在使用
mapreduce.reduce.resource.memory-mb 所有reduce任务的内存请求
mapreduce.reduce.cpu.vcores 不在使用
mapreduce.reduce.resource.vcores 所有reduce任务的cpu请求
mapreduce.reduce.resource. 所有reduce请求

注意,这些资源请求会通过被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 属性。

资源Profiles

Resource Profiles提供一个简单的方法给用户来请求一系列资源只是一个简单的profile,管理员管理资源消耗的一种方式
来配置资源类型,管理员必须设置
 yarn.resourcemanager.resource-profiles.enabled=ture。在yarn-site.xml,如下:


{
   "small": {
       "memory-mb" : 1024,
       "vcores" : 1
   },
   "default" : {
       "memory-mb" : 2048,
       "vcores" : 2
   },
   "large" : {
       "memory-mb": 4096,
       "vcores" : 4
   },
   "compute" : {
       "memory-mb" : 2048,
       "vcores" : 2,
       "gpu" : 1
   }
}

这是一个例子,用户有4个profile设置了不同的资源。

请求Profles

distrubuted shell是目前支持resource profile唯一的客户端。使用distrubuted shell,用户可以指定对应的profile名,如:

hadoop job $DISTSHELL -jar $DISTSHELL -shell_command run.sh -container_resource_profile small

posted on 2021-06-28 11:21  Fanr_Zh  阅读(72)  评论(0编辑  收藏  举报