1

Possible Duplicate:
Avoid linux out-of-memory application teardown

let me first say that I'm pretty new ti *nix systems and even more to server management. Anyway, I've got a little problem. I got VPS with 1gb mem, system is debian 6. I have few sites running on it, though some load can only be caused by one of them. Recently, OOMK started to kill mysql, causing wp and phpbb giving error that it can't connect to mysql server. Error itself is not good, especially if it happens at night and site becomes unavailable until I wake up and restart mysql. I have probably bad line in my cron which can be cause of it all (again, I'm new to it)

    */20 * * * *    sync; echo 3 > /proc/sys/vm/drop_caches        

Well, if you need any information, let me know, since I don't really know which information can be useful here. Also, I'd like to know if it's not too bad to have above cron task.

2 Answers2

2

There's no point in running echo 3 > /proc/sys/vm/drop_caches. As Linux runs out of memory it will automatically remove the buffers and caches, so you're actually harming system performance by forcing removal of useful i/o caching.

You really need to look at what could be consuming all the memory. Look at the following possible culprits:

  1. Apache - Max clients or number of servers too high. I presume you're running in pre-fork mode.
  2. PHP - Max memory, max upload, number of database connections
  3. Nightly cron jobs, like slocate
  4. Mysql memory usage.

UPD MySQL may be being killed by OOMKiller but not actually the cause. It could be just the largest single memory consumer.

Alastair McCormack
  • 2,203
  • 1
  • 16
  • 22
-1

Easy fix: Put more memory in the server.

But the question is why is the server running out of memory. Are you using InnoDB? Is the buffer pool size the right size? etc. More information is needed to help you out, to start with the output of htop and the mysql log.

Jeroen
  • 1,339