How does the MYSQL master and slave Synchronize automatically clean up the logs?

at present, the master and slave Synchronize of MYSQL has been done. Now we are considering the issue of log capacity, which has been exploded by binlog.
Master-slave mysql-bin and slave relay logs exist. I would like to ask if there is a way to automatically clean these two logs without affecting the master-slave data Synchronize. Baidu is in manual form, which is too troublesome.
my idea is that mysql-bin has pos. I don"t know if I can start with pos to clean up the log before a certain point, so there is no need to lock the table. But I don"t know how to make it happen.
if you are cleaning from the entire mysql-bin, you may need to use the lock table. Is it not easy to clean up automatically when using the lock watch?
or which god has a complete solution? Thank you for your advice!


binlog logs can be cleaned manually by time and binaries. The syntax is as follows

-sharp 
purge master logs before 'yyyy-mm-dd hh24:min:ss'

-sharp 
purge master logs to 'mysql-bin.xxxxxx';

by time : set up a scheduled task, regularly clean up the binary logs n hours / days ago
by file : set a scheduled task, regularly get the latest binlog log files ( show master logs ), and then reserve one or two binaries

.

or set the retention time of binlog logs to be shorter, for example, three days

set global expire_logs_days = 3;

risk Tip : if the binlog log is cleaned and the slave node fails to Synchronize in time, there is a risk of data inconsistency, so check where the slave node is read before cleaning. binlog Log will fill up the hard disk, which means that the hard disk space is unreasonable. It is recommended to increase the hard disk space or store the log files separately

manual cleaning of relay logs is not recommended. MySQL will automatically clean up after the execution of relay logs

Menu