MySQL binary log rotation
Posted on January 18, 2007 on 1:56 pm by glen | In General, MySQL, RedHat |We are running a MySQL replication setup, and find that the binary logs get very large, very quickly. Since MySQL didn’t come with a log rotation script, we rolled our own. Usage is simple:
At the top of the script are some definitions that you need to change for your setup:
- MYSQL_USER MYSQL_PASS - You will need to create a user in MySQL that has the RELOAD and SUPER privileges
- MYSQL_HOST - Where your MySQL server is located
- MYSQL_LOG_PATH MYSQL_LOG_NAME - where your binary logs are kept, and what they are called
- MYSQL_SLOW_LOG_NAME - the name of your slow log file
- MAX_LOG_DAYS - the number of days worth of old logs that you want to keep
Once you’ve configured these values, whack the script into cron and run it daily.
No Comments yet »
RSS feed for comments on this post. TrackBack URI