Tuesday, November 24, 2009

binlogs filling up disk

Problem: binlogs fill up storage space
Solution: manage your binlogs

Ever notice your disk utilization fly off the handle due to binlogs? There are a few commands and settings you need to be aware of.

Important SQL Commands

RESET MASTER

Removes all the binary logs listed in the index file, resets the index, and creates a new binary log file. Basically, it starts over the logging from scratch. This command is not safe for Replication environments.

PURGE { BINARY | MASTER } LOGS { TO 'log_name' | BEFORE datetime_expr }

Removes binary logs older than a certain date. This command is safe in Replication environments.

Important Settings in /etc/my.cnf

To limit the size of the individual binlog files:
max_binlog_size=200M

To automatically clean log files older than a certain number of days:
expire_logs_days = 14

No comments:

Post a Comment