CDH集之YARN性能调优
本⽂主要讨论CDH集的YARN调优配置,关于YARN的调优配置,主要关注CPU和内存的调优,其中CPU是指物理CPU个数乘以CPU核数,即Vcores = CPU数量*CPU核数。YARN是以container容器的形式封装资源的,task在container内部执⾏。
集配置
集的配置主要包括三步,第⼀是先规划集的⼯作主机以及每台主机的配置,第⼆是规划每台主机的安装的组件及其资源分配,第三是规划集的规模⼤⼩。
⼯作主机的配置
如下表所⽰:主机的内存为256G,4个6核CPU,CPU⽀持超线程,⽹络带宽为2G
主机组件数量⼤
总计描述
RAM256G256G内存⼤⼩CPU4648总CPU核数
HyperThreading CPU YES超线程CPU,使操作系统认为处理器的核⼼数是实际核⼼数的2倍,因此如果有24个核⼼的处理器,操作系统会认为处理器有48个核⼼
⽹络21G2G⽹络带宽
⼯作主机安装组件配置
第⼀步已经明确每台主机的内存和CPU配置,下⾯为每台节点的服务分配资源,主要分配CPU和内存
服务类别CPU核数内存(MB)描述
操作系统Overhead18192为操作系统分配1核8G内存,⼀般4~8G
其它服务Overhead00⾮CDH集、⾮操作系统占⽤的资源
Cloudera Manager agent Overhead11024分配1核1G
HDFS DataNode CDH11024默认1核1G
YARN NodeManager CDH11024默认1核1G
Impala daemon CDH00可选的服务,建议⾄少为impala demon分配16G内存
Hbase RegionServer CDH00可选的服务,建议12~16G内存
Solr Server CDH00可选的服务,最低1G内存
Kudu Server CDH00可选的服务,kudu Tablet server最低1G内存
Available Container Resources44250880剩余分配给yarn的container
container资源分配
Physical Cores to Vcores Multiplier:每个container的cpu core的并发线程数,本⽂设置为1
YARN Available Vcores:YARN可⽤的CPU核数=Available Container Resources * Physical Cores to Vcores Multiplier,即为44 YARN Available Memory:250880
集⼤⼩
集的⼯作节点个数:10
YARN配置
YARN NodeManager配置属性
配置参数值描述
<-mb250800分配的内存⼤⼩,每台节点剩余的内存
验证YARN的配置
登录YARN的resourcemanager的WEBUI::8088/,验证’Memory Total’与’Vcores Total’,如果节点都正常,那么Vcores Total应该为440,Memory应该为2450G,即250800/1024*10
YARN的container配置
YARN的container的Vcore配置
配置参数值描述
yarn.scheduler.minimum-allocation-vcores1分配给container的最⼩vcore个数
yarn.scheduler.maximum-allocation-vcores44分配给container的最⼤vcore数
yarn.scheduler.increment-allocation-vcores1容器虚拟CPU内核增量
YARN的container内存配置
配置参数值描述
yarn.scheduler.minimum-allocation-mb1024分配给container的最⼩内存⼤⼩,为1G
yarn.scheduler.maximum-allocation-mb250880分配给container的最⼤内存,等于245G,即为每台节点剩余的最⼤内存
yarn.scheduler.increment-allocation-mb512容器内存增量,默认512M
集资源分配估计
描述最⼩值最⼤值
根据每个container的最⼩内存分配,集最⼤的container数量为2450
根据每个container的最⼩Vcore分配,集最⼤的container数量为440
根据每个container的最⼤内存分配,集的最⼩container数为10
根据每个container的最⼤Vcores分配,集的最⼩container数为10
container合理配置检查
配置约束描述
最⼤的Vcore数量必须⼤于等于分配的最⼩Vcore
yarn.scheduler.maximum-allocation-vcores >= yarn.scheduler.minimum-allocation-vcores 分配的最⼤内存数必须⼤于等于分配的最⼩内存
yarn.scheduler.maximum-allocation-mb >= yarn.scheduler.minimum-allocation-mb
分配的最⼩核数必须⼤于等于0yarn.scheduler.minimum-allocation-vcores >= 0
分配的最⼤Vcore数必须⼤于等于1yarn.scheduler.maximum-allocation-vcores >= 1
每台主机分配给nodemanaer的vcore总数必须⼤
于分配的最⼩vcore数
每台主机分配给nodemanaer的vcore总数必须⼤
于分配的最⼤vcore数
度分配的最⼩内存
<-mb >= yarn.scheduler.maximum-allocation-mb
每台主机分配给nodemanaer的内存必须⼤于调
度分配的最⼤内存
<-mb >= yarn.scheduler.minimum-allocation-mb
container最⼩配置如果yarn.scheduler.minimum-allocation-mb⼩于1GB,container可能会被YARN杀死,因
为会出现OutOfMemory内存溢出的现象
MapReduce配置
jvm调优参数
ApplicationMaster配置
配置参数值描述
yarn.app.source.cpu-
vcores
1ApplicationMaster 的虚拟CPU内核数
yarn.app.source.mb1024ApplicationMaster的物理内存要求(MiB)
yarn.app.mapreduce.ammand-opts800传递到 MapReduce ApplicationMaster 的 Java 命令⾏参数,AM Java heap ⼤⼩,为
800M
堆与容器⼤⼩之⽐
配置参数值描述
task⾃动堆⼤⼩yes
mapreduce.-mb.ratio 0.8
Map 和 Reduce 任务的堆⼤⼩与容器⼤⼩之⽐。堆⼤⼩应⼩于容器⼤⼩,以允许 JVM 的某些开销,默认为0.8
map task配置
配置参数值描述
mapreduce.map.cpu.vcores1分配给map task的vcore数
mb1024分配给map task的内存数,1G
mapreduce.task.io.sort.mb400I/O 排序内存缓冲 (MiB),默认256M,⼀般不⽤修改
reduce task配置
配置参数值描述
MapReduce配置合理性检查
Application Master配置的合理性检查
yarn.scheduler.minimum-allocation-vcores <= yarn.app.source.cpu-vcores<= yarn-scheduler.maximum-allocation-vcores yarn.scheduler.minimum-allocation-mb <= yarn.app.source.cpu-vcores <= yarn.scheduler.maximum-allocation-mb
Java Heap⼤⼩是container⼤⼩的75%~90%: 太低会造成资源浪费, 太⾼会造成OOM
Map Task配置的合理性检查
Reduce Task配置的合理性检查
yarn.scheduler.minimum-allocation-vcores <= mapreduce.map.cpu.vcores <= yarn-scheduler.maximum-allocation-vcores
yarn.scheduler.minimum-allocation-mb <= mb <= yarn.scheduler.maximum-allocation-mb
Spill/Sort内存为每个task堆内存的40%~60%
Reduce Task配置的合理性检查
yarn.scheduler.minimum-allocation-vcores <= duce.cpu.vcores <= yarn-scheduler.maximum-allocation-vcores
yarn.scheduler.minimum-allocation-mb <= mb <= yarn.scheduler.maximum-allocation-mb
YARN和MapReduce配置参数总结
YARN/MapReduce参数配置描述
<-mb分配给container的内存⼤⼩
yarn.scheduler.minimum-allocation-vcores分配给container的最⼩虚拟cpu数
yarn.scheduler.maximum-allocation-vcores分配给container的最⼤虚拟cpu数
yarn.scheduler.increment-allocation-vcores分配给container的递增虚拟cpu数
yarn.scheduler.minimum-allocation-mb分配给container的最⼩内存⼤⼩
yarn.scheduler.maximum-allocation-mb分配给container的最⼤内存
yarn.scheduler.increment-allocation-mb分配给container的递增内存⼤⼩
yarn.app.source.cpu-vcores ApplicationMaste的虚拟cpu数
yarn.app.source.mb ApplicationMaste的内存⼤⼩
mapreduce.map.cpu.vcores map task的虚拟CPU数
mb map task的内存⼤⼩
mapreduce.task.io.sort.mb I/O排序内存⼤⼩
note:在CDH5.5或者更⾼版本中,参数mapreduce.map.java.opts, duce.java.opts, yarn.app.mapreduce.ammand-opts会基于container堆内存的⽐例进⾏⾃动配置