ubuntu mysql 内存满了,自动重启MySQL时的Ubuntu在EC2上运行时内存不足,例如微杀死它...

When the system runs out of memory, ubuntu 12.04 kills the mysql process:

Out of memory: Kill process 17074 (mysqld) score 146 or sacrifice child

So the process ends up killed.

This happens at peaks of server load and mainly because of apache getting wild and eating the remaining available memory. Possible approaches could be:

Change somewhere somehow the priority of mysql, so it's not killed (probably a bad fix as something else will be killed)

Monitor the status of mysql and restart automatically whenever it's killed (the one I'm thinking about, but don't know how to do it).

How do you see it?

解决方案

Abrupt termination of a database server is a very serious crash. You need to avoid this in a production system, because it may not restart cleanly.

The database server is a shared resource, and should almost never terminate in an unplanned fashion in production. The only thing that should cause unplanned termination is a catastrophic hardware or power failure. Most properly configured production data base servers have an unplanned termination once every ten years or less frequently. Seriously.

What to do?

Fix your apache configuration. Limit the number of worker threads and processes it can use, so it can't run wild. Learn how to do this. It's vital. See here: http://httpd.apache.org/docs/current/mod/mpm_common.html#maxrequestworkers

Fix the defects in your web app that are causing your apache to run wild.

If you can, move your mysqld server to a different server machine from apache, so the two don't contend for the same hardware resources.

Configure your mysqld to limit the number of connections it will accept from apache worker threads or other clients. Your web app probably handles the situation where a worker thread needs to wait for a connection. See here. http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_connections

Are you on an EC2 micro instance? You need to do some serious tuning. See here: http://ubuntuforums.org/showthread.php?t=1979049

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值