ubuntu – 有没有办法自动防止内存不足?

前端之家收集整理的这篇文章主要介绍了ubuntu – 有没有办法自动防止内存不足?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我经常在我的VPS ubuntu服务器上耗尽内存.我希望有一种方法可以在内存开始耗尽时简单地重启apache2,因为这似乎可以解决问题.或者我只是懒得解决这个问题?我在服务器上的内存有限……

好的,更多信息:

我正在运行apache2 prefork,这是我的内存设置(我一直在调整它们……):

  1. StartServers 3
  2. MinSpareServers 1
  3. MaxSpareServers 5
  4. MaxClients 150
  5. MaxRequestsPerChild 1000

VPS有1 GB的ram,运行ubuntu 11.04 32位.

至于脚本,我有一个带有5个博客wordpress网络,一个AskBot(一个python / django stackexchange克隆)的安装,以及一个未真正使用的MediaWiki安装.还有一个自制的mp3脚本访问getid3库以显示播客列表的信息,它似乎抛出一些PHP错误,不知道这是否是罪魁祸首……

Monit可以做到这一点.

您可以使用配置行,例如:

  1. check process apache
  2. with pidfile "/var/lock/apache/httpd.pid"
  3. start program = "/etc/init.d/httpd start" with timeout 60 seconds
  4. stop program = "/etc/init.d/httpd stop"
  5. if 2 restarts within 3 cycles then timeout
  6. if totalmem > 100 Mb for 5 cycles then restart
  7. if children > 255 for 5 cycles then stop
  8. if cpu usage > 95% for 3 cycles then restart
  9. if Failed port 80 protocol http then restart
  10. group server
  11. depends on httpd.conf,httpd.bin

(自this config example on monit.com修改)

这可能会影响前面提到的ulimit选项.

重启服务是一个绑定.你应该试着找出它泄漏记忆的原因.

猜你在找的Ubuntu相关文章