YARN学习总结-第六节-YARN资源配置

YARN资源配置

YARN支持扩展资源模型,默认,YARN跟踪CPU和内存对于所有节点、应用和队列。但是,资源定义为任何可数的资源。一个资源是在容器运行时被消耗,之后被释放。CPU和内存 都是可数资源,其他资源如GPU、软件许可。

此外,YARN还支持指定资源配置,例如ECS,小规格就是1核1G,中等规格就是2核4G,大规格就是4核16G。

支持下面的配置:

yarn-site.xml

yarn.resourcemanager.resource-profiles.enabled:是否开启resource profile

resource-types.xml

yarn.resource-types:逗号分隔的资源,不包括memory,memory-mb,vcores

yarn.resource-types.<resource>.units:资源的单元

yarn.resource-types.<resource>.minimum-allocation:对于指定的资源的最小请求。

yarn.resource-types.<resource>.maxinum-allocation:对于指定的资源的最大请求。

node-resource.xml

yarn.nodemanager.resource-type<resource>:从节点管理器可以获得的资源数量。

注意:resource-types.xml和node-resource.xml应该放置到与yarn-site.xml同样的目录。

YARN资源模型

去定义一种新的资源如下例子:

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

一个有效的资源名称,必须以字母开头,并且只能包含字母,数字,和点号,下划线,连字符等任意字符。

每个资源类型会定义一个可选的unit属性。

p:pico

n:nano

u:micro

m:milli

k:kilo

M:mega

G:giga

T:tera

P:peta

Ki:binary kilo,i.e. 1024

Mi:binary mega,i.e. 1014^2

Gi:1024^3

Ti:1024^4

Pi:1024^5

下面的配置可以在yarn-site.xml或者resource-types.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>

在nodemanager上独立定义可以从节点上获得的资源,可以配置到yarn.site.xml或者noderesource.xml文件中。

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

注意:这里这些资源使用的单位不需要和资源管理器中列出的进行匹配,如果不匹配,资源管理器会自动转换。

MapReduce会请求3中不同的容器,application master容器,map容器,reduce容器。每种容器有一些相应的属性。

可以设置的MapReduce参数如下:

yarn.app.mapreduce.am.resource.mb:用yarn.app.mapreduce.am.resouce.memory-mb代替,默认为1536

yarn.app.mapreduce.am.resouce.memory:用yarn.app.mapreduce.am.resouce.memory-mb代替,默认为1536

yarn.app.mapreduce.am.resouce.memory-mb:默认为1536

yarn.app.mapreduce.am.resouce.cpu-vcores:用yarn.app.mapreduce.am.resouce.vcores代替,默认为1

yarn.app.mapreduce.am.resouce.vcores:默认为1

yarn.app.mapreduce.am.resouce.<resouce>:

mapreduce.map.resouce.mb:用mapreduce.map.resouce.memory-mb代替,默认为1024

mapreduce.map.resouce.memory:用mapreduce.map.resource.memory-mb代替,默认为1024

mapreduce.map.resouce.memory-mb:默认为1024

mapreduce.map.cpu.vcores:用mapreduce.map.resource.vcores代替,默认为1

mapreduce.map.resource.vcores:默认为1

mapreduce.map.resouce.<resouce>:设置所有map任务请求的资源数量。

mapreduce.reduce.memory.mb:用mapreduce.reduce.resource.memory-mb代替,默认为1024

mapreduce.reduce.resource.memory:用mapreduce.reduce.resource.memory-mb代替,默认为1024

mapreduce.reduce.resouce.memory-mb:默认为1024

mapreduce.reduce.cpu.vcores:用mapreduce.reduce.resouce.vcores代替,默认为1

mapreduce.reduce.resource.vcores:默认为1

mapreduce.reduce.resouce.<resouce>:设置所有reduce任务请求的资源数量。

注意:这些配置,可以被修改。

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,

yarn.scheduler.increment-allocation-vcores

Resource Profiles

{
    "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
    }
}

如何使用?

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

猜你喜欢

转载自blog.csdn.net/qq_20995587/article/details/82106700