我正在尝试做yum update
并得到“MemoryError”。服务器(OpenVZ box)有 2G RAM 和 Percona MySQL 服务器,配置了 1G InnoDB 缓冲区。操作系统为 CentOS 6.5,内核 2.6.32-openvz-042stab088.4-amd64。
free -m
输出:
total used free shared buffers cached
Mem: 2048 728 1319 0 0 21
-/+ buffers/cache: 706 1341
Swap: 2048 0 2048
在宿主机上,盒子内存配置为:
vzctl set 101 --physpages 0:2G --swappages 0:2G --kmemsize unlimited --privvmpages 2000M:2G --vmguarpages 2000M:2G --oomguarpages 2G --save
当我停止 MySQL 时,yum update
工作正常。yum update
如果仍然有超过 1G 的可用 RAM,为什么 MySQL 会失败?
完整的错误输出是:
yum update
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: mirror.mel.bkb.net.au
* contrib: mirror.mel.bkb.net.au
* epel: mirror.overthewire.com.au
* extras: mirror.mel.bkb.net.au
* updates: mirror.optus.net
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in <module>
yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/yummain.py", line 285, in user_main
errcode = main(args)
File "/usr/share/yum-cli/yummain.py", line 136, in main
result, resultmsgs = base.doCommands()
File "/usr/share/yum-cli/cli.py", line 434, in doCommands
self._getTs(needTsRemove)
File "/usr/lib/python2.6/site-packages/yum/depsolve.py", line 99, in _getTs
self._getTsInfo(remove_only)
File "/usr/lib/python2.6/site-packages/yum/depsolve.py", line 110, in _getTsInfo
pkgSack = self.pkgSack
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 887, in <lambda>
pkgSack = property(fget=lambda self: self._getSacks(),
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 683, in _getSacks
self.plugins.run('exclude')
File "/usr/lib/python2.6/site-packages/yum/plugins.py", line 184, in run
func(conduitcls(self, self.base, conf, **kwargs))
File "/usr/lib/yum-plugins/priorities.py", line 129, in exclude_hook
repopkgs_archless = _pkglist_to_dict(conduit.getPackages(repo), repo.priority)
File "/usr/lib/python2.6/site-packages/yum/plugins.py", line 592, in getPackages
return self._base.pkgSack.returnPackages(arg)
File "/usr/lib/python2.6/site-packages/yum/packageSack.py", line 499, in returnPackages
ignore_case=ignore_case)
File "/usr/lib/python2.6/site-packages/yum/sqlitesack.py", line 1646, in returnPackages
pkgobjlist = self._buildPkgObjList(repoid, patterns, ignore_case)
File "/usr/lib/python2.6/site-packages/yum/sqlitesack.py", line 1610, in _buildPkgObjList
po = self._packageByKeyData(repo, x['pkgKey'], x)
File "/usr/lib/python2.6/site-packages/yum/sqlitesack.py", line 754, in _packageByKeyData
po = self.pc(repo, data)
File "/usr/lib/python2.6/site-packages/yum/sqlitesack.py", line 187, in __init__
self._loadedfiles = False
MemoryError
这里有类似的问题,但没有帮助,因为我有更多的 RAM。
首先我建议你启用 vSwap 内存模型,因为它比旧的 UBC 风格的系统更简单、更可靠。有了它,您可以将其替换
vzctl set 101 --physpages 0:2G --swappages 0:2G --kmemsize unlimited --privvmpages 2000M:2G --vmguarpages 2000M:2G --oomguarpages 2G --save
为vzctl set 101 --physpages 2G --swappages 2G --save
在此之后,请告诉我这个命令结果:
cat /proc/user_beancounters
这个问题看起来像内存问题,但它与无法由 free 或 top 显示的二级内存限制有关(仅与 cat /proc/user_beancounters 一起使用)。