执行Hive SQL/MR 报错:Current usage: 77.8mb of 512.0mb physical memory used; 1.1gb of 1.0gb virtual memory used. Killing container.

从错误消息中,可以看到使用的虚拟内存超过了当前1.0gb的限制。这可以通过两种方式解决:

禁用虚拟内存限制检查

YARN只会忽略该限制;为此,请将其添加到您的yarn-site.xml

<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
<description>Whether virtual memory limits will be enforced for containers.</description>
</property>

此设置的默认值为true

增加虚拟内存与物理内存的比率

yarn-site.xml更改中,此值将高于当前设置

<property>
<name>yarn.nodemanager.vmem-pmem-ratio</name>
<value>5</value>
<description>Ratio between virtual memory to physical memory when setting memory limits for containers. Container allocations are expressed in terms of physical memory, and virtual memory usage is allowed to exceed this allocation by this ratio.</description>
</property>

默认是 2.1

还可以增加分配给容器的物理内存量。

注意:更改配置后不要忘记重新启动yarn。


如果不能修改集群配置,我们可以参考这么做:

-Dmapreduce.map.memory.mb=4096

在运行MR的作业中我们需要关心一下几个参数:

yarn.nodemanager.resource.memory-mb
yarn.scheduler.minimum-allocation-mb
yarn.scheduler.maximum-allocation-mb
yarn.nodemanager.vmem-check-enabled
yarn.nodemanager.vmem-pmem-ratio
Author: Tunan
Link: http://yerias.github.io/2020/03/25/error/3/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.