1

Is there any way to do this? Specify a different directory for currently active binary log.

(It would nice if possible, because then we could store past binary logs in a compressed file system without compromising write performance of the current log.)

2
  • Interesting, there's no different settings for active vs non-active binary logs. What compressed filesystem are you planning on using? Given mysql writes sequentially to the file, and reads sequentially to serve the needs of a replication slave (which if up to date will be served from the OS page cache), is there any downside to just using the compressed filesystem for all binary logs? If you avoid sync_binlog=1 then overheads, shouldn't impact the server operation (in theory). Commented Sep 16, 2018 at 23:37
  • Didn't have any specific file system in mind, any would do the job for older logs anyway. You may be right that it's fine for production too, with sync_binlog off. There has to be a non-compressed filesystem for the database anyway, so it would be ideal to use it for the current log file too, but I agree a compressed system might still work if necessary. Commented Sep 17, 2018 at 7:15

1 Answer 1

0

Why? Replication was not designed with the thought of keeping binlogs for very long. Very few systems ask to keep them longer than 2 weeks. To use very old logs is costly due to the effort to rebuild the system and replay the logs. It is usually better to periodically take some form of snapshot.

That being said, I will get back to your Question. How about the following... You write a shell script that runs daily and does:

  • If less than X GB of data in uncompressed binlogs, exit silently.
  • Copy the oldest binlog to the compressed filesystem.
  • Replace that binlog with a soft link to the copy.

Meanwhile, set up MySQL to never purge binlogs, and add something to your script to do the equivalent purging. (I think there are some edge cases that will go haywire otherwise.)

Any reference from MySQL to the compressed binlogs should work fine; however there won't be any (unless a Slave is more than X GB behind).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.