On 1/12/2011 10:59 AM, Kaddeh wrote:
So, I have run into an interesting problem while building out a web
server for a client which I haven't come across before and I was hoping
that the list would be a good way for me to find the answer.
A little beckground on the systems:
P4 @ 3.0Ghz
2GB PC2 4200
2x 250GB drives in RAID1
The system configurations are default for the most part with the server
running MySQL and Apache.
The problem that I am running into at this point, however is that the
machine seems to run out of memory and will segfault either apache or
mysql when does so, when apache segfaults, it is a recoverable error,
when mysql does it, mysql can't recover short of restarting it.
At this point, I have found a soft fix by running a cron job every 6
hours or so to clear the cached memory, which seems to be the problem,
however, I would like to find a more permanent fix to this issue.
Anything that would help at this point would be much appreciated.
Cheers
Kad

Overall I'd expect your Mysql is running slow, which causes Apache to back up, which create more Apache children while your code blocks on the db, which then uses all the RAM.

1. Assuming you're running prefork, Turn KeepAlives Off if you haven't already. That'll reduce the number of Apache threads sitting around doing nothing but using your RAM.

2. The default my.conf in Gentoo (and nearly all distros) is configured to use 64MB. You should bump this up to 512MB total. The two settings I would touch are the following and THEY ARE SEPARATE POOLS that do not share configured memory with each other. Configure accordingly.
innodb_buffer_pool_size = 16M
key_buffer = 16M

Both variables are dynamic and can be set from with Mysql use set variables key_buffer='10240000'; syntax.

Assuming you use Innodb tables I'd try 256MB for that setting and 128MB for the key_buffer and see how it goes.

3. Mysql slow query log. Turn it on and look at it. Your db design sounds sketchy at best and I'd be surprised if your weren't seeing a ton of slow queries especially with no db tuning.

4. /tmp is how big? Make sure it's a couple of gigs so that Mysql can build tmp tables in it. Again your db design is strange enough that you might be generating large tmp tables that file /tmp (and / if you haven't separated them) and causes Mysql problems. This is a fairly common problem in my experience. The simplest solution is:
sudo mkdid -p /home/mysql
sudo chown -R mysql: /home/mysql
vi /etc/mysql/my.cnf and change to tmpdir = /home/mysql/
sudo /etc/init.d/mysql restart

Yes, tmpdir is *not* a dynamic variable so you will have to restart Mysql to make this change.

kashani

Reply via email to