Yarn的生产参数调优

官网默认参数

https://hadoop.apache.org/docs/r3.1.1/hadoop-yarn/hadoop-yarn-common/yarn-default.xmlguanYarn的生产参数调优

参数调优

1.Container

Container就是Yarn中的一个动态资源分配的概念。其拥有一定的内存+核数(memory+vcore),由RM分配给ApplicationMaster或MapTask或ReduceTask,之后我们需要的程序就在Container为基础的容器中运行起来。

1.1生产如何调优Container参数?

1.1.1 环境假设:128Gmemory 16物理core

备注:物理核:虚拟核:1:2
pcore:vcore=1:2
16物理核也就是32虚拟核
假设:装完CentOS,消耗内存1G,系统预览15%-20%内存,以防全部使用导致系统夯住 和 oom机制事件,或者给未来部署组件预览点空间。此外,本机器还有DN和NM两个进程分别占用2G和4G内存。
预留内存:128*20%=25.6G ==26G
剩余内存:128-26-2-4=96G

1.1.2 container内存

yarn.nodemanager.resource.memory-mb 96G
yarn.scheduler.minimum-allocation-mb 1G 极限情况下,只有96个container 内存1G
yarn.scheduler.maximum-allocation-mb 96G 极限情况下,只有1个container 内存96G

container的内存会自动增加,默认1g递增
container:1-96个

1.1.3 container虚拟核

物理核:虚拟核 =1:2 32vcore
yarn.nodemanager.resource.pcores-vcores-multiplier 2
yarn.nodemanager.resource.cpu-vcores 32
yarn.scheduler.minimum-allocation-vcores 1 极限情况下,只有32个container
yarn.scheduler.maximum-allocation-vcores 32 极限情况下,只有1个container
container:1-32个

1.1.4 官方建议

cloudera公司推荐,一个container的vcore最好不要超过5,那么假设我们设置4
yarn.scheduler.maximum-allocation-vcores 4 极限情况下,只有8个container

1.1.5 综合memory+vcore

确定 vcore=4 那么container =32/4=8个
yarn.nodemanager.resource.memory-mb 96G
yarn.scheduler.minimum-allocation-mb 1G
yarn.scheduler.maximum-allocation-mb 12G 极限container 8个
当然当spark计算时内存不够大,这个参数肯定要调大,
那么这种理想化的设置个数必然要打破,以memory为主

yarn.nodemanager.resource.cpu-vcores 32
yarn.scheduler.minimum-allocation-vcores 1
yarn.scheduler.maximum-allocation-vcores 4 极限container 8个

8个container 12G 4vcore

yarn.nodemanager.resource.memory-mb 96G
yarn.scheduler.minimum-allocation-mb 1G
yarn.scheduler.maximum-allocation-mb 8G

12container 12*2=24

yarn.nodemanager.resource.cpu-vcores 32
yarn.scheduler.minimum-allocation-vcores 1
yarn.scheduler.maximum-allocation-vcores 2
16 container*8g

详细可参考:http://blog.itpub.net/30089851/viewspace-2127851/
https://blog.csdn.net/gszhihan/article/details/95754523