Wednesday, July 09, 2008

automating mysqltuner

I found the mysqltuner a while back and had been using it on one of my servers sporadically. I suddenly thought... why don't I run it automatically via a cron every week and test the server optimisation. Easy...
sudo -s
wget http://mysqltuner.com/mysqltuner.pl
chmod +x mysqltuner.pl
cp ./mysqltuner.pl to /usr/local/bin/mysqltuner
Ensure that it's in the right place by running it and then optimise the current mysql server and restart it:
mysqltuner
joe /etc/mysql/my.cnf
/etc/init.d/mysql restart
Now we need to add a cron entry to make it run every week.
crontab -e
43 4 * * * thur mysqltuner
And that's it, saving the crontab file will install it and on the next thursday at 4:43 in the morning, the optimiser will run as root and email the server admin the output.

No comments: