概述
YARN支持可扩展资源模块,默认YARN会跟着所有node,应用和队列中的内存和cpu,但是资源只能扩展可计数的资源,比如cpu ,内存,但是GPU和软件许可是不行的。
配置
yarn-site.xml
属性 | 值 |
---|---|
yarn.resourcemanager.resource-profiles.enabled | 是否启动资源配置 |
resource-types.xml
属性 | 值 |
---|---|
yarn.resource-types | 资源类型,逗号分割 |
yarn.resource-types. |
指定资源的单位 |
yarn.resource-types. |
特定资源最小请求数 |
yarn.resource-types. |
特定资源最大请求数 |
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.
<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 -shell_command run.sh -container_resource_profile small
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
2018-06-28 firewall防火墙使用