當運行中出現Container is running beyond physical memory這個問題出現主要是因為物理內存不足導致的,在執行mapreduce的時候,每個map和reduce都有自己分配到內存的最大值,當map函數需要的內存大於這個值就會報這個錯誤,解決方法:
在mapreduc-site.xml配置里面設置mapreduce的內存分配大小
<property> <name>mapreduce.map.memory.mb</name> <value>2048</value> </property>
當運行中提示running beyond virtual memory limits. Current usage: 32.1mb of 1.0gb physical memory used; 6.2gb of 2.1gb virtual memory used. Killing container。
該錯誤是YARN的虛擬內存計算方式導致,上例中用戶程序申請的內存為1Gb,YARN根據此值乘以一個比例(默認為2.1)得出申請的虛擬內存的 值,當YARN計算的用戶程序所需虛擬內存值大於計算出來的值時,就會報出以上錯誤。調節比例值可以解決該問題。具體參數為:yarn-site.xml 中的yarn.nodemanayger.vmem-check-enabled
<property> <name>yarn.nodemanager.vmem-check-enabled</name> <value>false</value> </property>
<property> <name>yarn.nodemanager.vmem-pmem-ratio</name> <value>5</value> </property>