报错片段如下:
Container[pid=28920,containerID=container_xxx] is running beyond virtual memory limits.Current usage:1.2 GB of 1 GB physicalmemory used; 2.2 GB of 2.1 GB virtual memoryused. Killing container.
原因:从机上运行的Container试图使用过多的内存,而被NodeManager kill掉了。
[摘录] The NodeManager is killingyour container. It sounds like you are trying to use hadoop streaming which isrunning as a child process of the map-reduce task. The NodeManager monitors theentire process tree of the task and if it eats up more memory than the maximumset in mapreduce.map.memory.mb or mapreduce.reduce.memory.mb respectively, wewould expect the Nodemanager to kill the task, otherwise your task is stealingmemory belonging to other containers, which you don't want.
解决方法:
mapred-site.xml中设置map和reduce任务的内存配置如下:(value中实际配置的内存需要根据自己机器内存大小及应用情况进行修改,如报错时使用的物理内存达1.2G,虚拟内存达2.2G,在物理内存充足的情况下,可设的尽量大些,避免输入文件量大再超标)
<property>
<name>mapreduce.map.memory.mb</name>
<value>1536</value>
</property>
<property>
<name>mapreduce.map.java.opts</name>
<value>-Xmx1024M</value>
</property>
<property>
<name>mapreduce.reduce.memory.mb</name>
<value>3072</value>
</property>
<property>
<name>mapreduce.reduce.java.opts</name>
<value>-Xmx2560M</value>
</property>
附:MapReduce作业配置参数
可在客户端的mapred-site.xml中配置,作为MapReduce作业的缺省配置参数。也可以在作业提交时,个性化指定这些参数。
参数名称 | 缺省值 | 说明 |
mapreduce.job.name | | 作业名称 |
mapreduce.job.priority | NORMAL | 作业优先级 |
yarn.app.mapreduce.am.resource.mb | 1536 | MR ApplicationMaster占用的内存量 |
yarn.app.mapreduce.am.resource.cpu-vcores | 1 | MR ApplicationMaster占用的虚拟CPU个数 |
mapreduce.am.max-attempts | 2 | MR ApplicationMaster最大失败尝试次数 |
mapreduce.map.memory.mb | 1024 | 每个Map Task需要的内存量 |
mapreduce.map.cpu.vcores | 1 | 每个Map Task需要的虚拟CPU个数 |
mapreduce.map.maxattempts | 4 | Map Task最大失败尝试次数 |
mapreduce.reduce.memory.mb | 1024 | 每个Reduce Task需要的内存量 |
mapreduce.reduce.cpu.vcores | 1 | 每个Reduce Task需要的虚拟CPU个数 |
mapreduce.reduce.maxattempts | 4 | Reduce Task最大失败尝试次数 |
mapreduce.map.speculative | false | 是否对Map Task启用推测执行机制 |
mapreduce.reduce.speculative | false | 是否对Reduce Task启用推测执行机制 |
mapreduce.job.queuename | default | 作业提交到的队列 |
mapreduce.task.io.sort.mb | 100 | 任务内部排序缓冲区大小 |
mapreduce.map.sort.spill.percent | 0.8 | Map阶段溢写文件的阈值(排序缓冲区大小的百分比) |
mapreduce.reduce.shuffle.parallelcopies | 5 | Reduce Task启动的并发拷贝数据的线程数目 |