Binlog Trim

Nick Lamb -

Binglog Trim is a script to trim binlogs according to the retention policy

Usage: binlog-trim [options]

Options:
-h, --help show this help message and exit
-H HOST, --host=HOST 
-P PORT, --port=PORT sql port, default is mysql port: 3306
-u USER, --user=USER username, default is root
-p PASSWD, --passwd=PASSWD
-n NUM_FILES, --num-files=NUM_FILES
number of files to trim a time
-d, --dry do not perform any actual trims
-k KEEP_DAYS, --days=KEEP_DAYS
keep this many days of binlogs
-i INTERVAL, --interval=INTERVAL
seconds between trims
-b BINLOG_NAME, --binlog_name=BINLOG_NAME
name of binlog to trim; must specify if multiple
binlogs exist
-M MAX_RUN_TIME_MINS, --max-run-time-mins=MAX_RUN_TIME_MINS
maximum time (minutes) script may run
-V, --version 
-N, --new-method use alternate method of SHOW BINLOG FILES for faster
performance

binlog-trim is generally deployed as a cron job on one of the nodes. An example entry to run once a day at 5:35UTC, with a retention policy of 7 days, trimming no more than 15 files at a time, with a minimum 60 second pause between trims, and operating on the binlog called clustrix-bin:

35 5 * * * root /bin/binlog-trim -H localhost -i 60 -k 7 -n 15 -b clustrix-bin 2>&1 >> /var/log/binlog-trim.log 

Note that the INTERVAL is a minimum wait between trims; there is additional logic in the script to prevent the trims from building up too much cleanup work (the logs will indicate this with 'waiting for bigc to pass trim').

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk