Friday, July 15, 2011

mysql: age-based purging of binary logs

how to purge old binary logs?

note: if you use your binary logs for replication make sure your slave db server is replicating and is up to date before you start purging. you can do that by issuing:
slave mysql> show slave status \G

see a list of binary logs on your master db server:
master mysql> show binary logs;

then manually purge logs as you want (i drop 3 month old logs):
master mysql> purge master logs before adddate(Now(), interval -90 day);

or you can automatically do this through a system variable in your mysql configuration file:
expire_logs_days = 90
(i have yet to try this)

you can also purge logs by deleting log files from your master db server's mysql directory. just make sure that the files you delete are not the ones currently used by your master and slave db servers.

why purge your binary logs? hard disk drives may be cheap these days, but i ain't buyin!!

No comments:

Post a Comment

SSH : No matching host key type found. Their offer: ssh-rsa,ssh-dss

Got this while connecting to my mikrotik router via ssh   Unable to negotiate with <ip address> port <ssh port>: no matching hos...