Re: Optimize All Tables
Posted by: Alex Sadykov
Date: July 17, 2008 12:00PM

Figured it out.

i setup 2 scripts

1. run_optimize_mydb.sh

#!/bin/sh
HOSTNAME=`/bin/hostname`
/mydb/backup/optimize_mydb.sh $* | /usr/bin/mail -s "Optimization of mydb complete on $HOSTNAME" myemailaddress@mydomain.com


2.optimize_mydb.sh

#!/bin/sh
#this script optimizes all mydb tables
#Runs a flush tables command afterwards
date
mysqlcheck --databases mydb --optimize -ublah -plah;
mysql -ublah -pblah mydb -e'flush tables';
date

then i setup cron to execute ./run_optimize_mydb.sh
Once it's done i get an email like this:

From: root [mailto:root@hostname.com]
Sent: Thursday, July 17, 2008 9:43 AM
To: myemailaddress@mydomain.com
Subject: Optimization of mydb complete on hostname

Thu Jul 17 09:43:28 EDT 2008
mydb.table1 OK
mydb.table2 OK
mydb.table2 OK
Thu Jul 17 09:45:28 EDT 2008

I've got chained replication setup and it turns out all slave databases get optimized also.

If anyone can suggest how to have it all in one file I would greatly appreciate it.
Thank you.



Edited 2 time(s). Last edit at 07/17/2008 12:02PM by Alex Sadykov.

Options: ReplyQuote


Subject
Written By
Posted
July 16, 2008 12:53PM
Re: Optimize All Tables
July 17, 2008 12:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.