Yarn运行Job报错:container is running beyond virtual memory limits

时间:2022-06-21 12:26:08

在Spark on Yarn集群上运行Spark jar包,结果报错:

container *** is running beyond virtual memory limits……


问题分析:

yarn-site.xml 中关于资源的配置有问题。

yarn.nodemanager.resource.memory-mb = 3072,默认8192
yarn.scheduler.minimum-allocation-mb =150
yarn.scheduler.maximum-allocation-mb 默认8192
yarn.nodemanager.vmem-pmem-ratio 默认 2.1


其中 yarn.scheduler.maximum-allocation-mb 和 yarn.nodemanager.vmem-pmem-ratio 都用了默认的配置。

一个container可用的最大虚拟内存是yarn.nodemanager.vmem-pmem-ratio与yarn.scheduler.minimum-allocation-mb的乘积,

即2.1 * 150m = 315mb。实际运行的时候,应用的虚拟内存超过了这个数值,所以报错。

所以,将yarn.nodemanager.vmem-pmem-ratio与yarn.scheduler.minimum-allocation-mb两个或其中一个值设置大一点,问题就

解决了。


另外,运行参数解释:

yarn.nodemanager.resource.memory-mb      默认8192
yarn.nodemanager.vmem-pmem-ratio            默认2.1
yarn.scheduler.minimum-allocation-mb          默认1024
yarn.scheduler.maximum-allocation-mb         默认8192

前两个是NM节点的资源参数,后两个是RM的资源参数。大小关系如下:

yarn.scheduler.minimum-allocation-mb < yarn.scheduler.maximum-allocation-mb < yarn.nodemanager.resource.memory-mb

单个容器可申请的最小yarn.scheduler.minimum-allocation-mb与最大内存yarn.scheduler.maximum-allocation-mb,应用在运行申请内存时不能超过最大值,小于最小值则分配最小值。这两个值不能动态修改。

如果向RM请求的内存小于yarn.scheduler.minimum-allocation-mb时(比如mapred-site.xml中配置mapreduce.reduce.memory.mb),按yarn.scheduler.minimum-allocation-mb分配 。



参考链接:

http://blog.chinaunix.net/uid-28311809-id-4383551.html

http://hadoop.apache.org/docs/r2.7.3/hadoop-yarn/hadoop-yarn-common/yarn-default.xml