Our company web sites have just been moved from a shared host to a VDS, as the hosting company plans on retiring the less than completely reliable shared hosting server(s).
The VDS only has 256MB of RAM and hosts a few sites, all but one of which are very simple static sites with just a few pages and combined serve less than 20-30 visitors per day.
Our primary site, which runs a somewhat customized version of OSCommerce, is also low traffic (rarely more than 10 or so concurrent users) but does require MySQL. Unfortunately, since the move mysqld keeps crashing due to insufficient memory. I've edited the Apache config a bit (to reduce the number of threads) to ease the load but that's only sidestepping the real issue.
The server has no swap space but it does have considerably more disk space than we require, so I'm thinking about using some of that space for swap. I know that won't exactly help performance but we can live with that.
How can I create a swap file and enable it while the server is running? The OS is CentOS 5.5 (final) and Linux is not my native tongue.
Update: For anyone who may be wondering about the results, since implementing the swap file as described by quanta the server has not only been stable, with no more crashes of mysqld, it is actually serving pages faster than it did before. The performance gain is contrary to what I expected but I'm delighted to be wrong in this instance.
Assuming that you want to create 512MB swap file:
Setup swap area with:
Activate it:
Add to
/etc/fstab
for permanent:and verify with
free -m
.