4 Answers
4

Setup a second server as a slave. You probably want a master/master setup so either host can take writes. Move the IP over to this second machine. Now you can do your maint on the first machine. This will minimize the downtime for the MySQL service.

But as a secondary point: You don't have to move MySQL (unless it's really the only thing taking up substantial space on /var): If you have lots of junk in /var/log, /var/spool, /var/www, etc. you can move those to separate filesystems too.

In reality MySQL is probably your 1000-pound gorilla on the partition, but if you're REALLY crunched for space (and just deleting other stuff isn't an option) you can move it around as a stopgap while you get your slave server up.

Agreed with JennyD's answer, there is no way to do it without shutting the database down.

However if the mysql database itself is not that large and the system's I/O speed reasonably high you could easily do this withy minimal down time, just by chaining a few commands together and running it at a time usage is low. I've successfully done this a number of times for critical mysql databases. Perhaps announce the maintenance and do a few test runs on a test system to find out how long it takes.

It's a bit crude but effective. And practical in many cases (probably in all but the most mission critical "can't ever be down" systems). The "&&" in the command makes sure that if a previous command fails it will not continue.