Properly cleaned binlog log

Summary: MySQL is the binlog log data in the database changes, facilitate analysis of data points based on the time and location-based recovery, but also an increasing binlog, take up a lot of disk space, therefore, to the right to use binlog safe way to clean out the useless part of the log.

[Method] manually clean binlog
before cleaning preparation:
① Check the main library and the binlog library is using which file
Show Master Status \ G 
Show Slave Status \ G    
② before deleting binlog log, first binlog log backups to Just in case

Started working delete binlog:
purge logs before'2016-09-01 17:20:00 Master '; // delete the log before the specified date index binlog log file
or
purge master logs to'mysql-bin.000022'; // delete the specified log file log index binlog log file
Note: the
time and file name must not be wrong, especially in time of the file name and serial number to prevent accidentally delete the binlog being used! ! !
Do not delete binlog being used! ! !
Using this syntax, the corresponding path will be the corresponding file and mysql-bin.index dropped.

[Method] By providing two binlog expiration time, the system automatically deletes files binlog
MySQL> Show Variables like 'expire_logs_days';  
+ + ---- ------------------ + ---  
| variable_name | Value |  
+ ------------------ + ------- +  
| expire_logs_days | 0 |  
+ ------- + ------- + -----------  
MySQL> Global expire_logs_days sET = 30; # binlog set number of days expired
NOTE:
to the appropriate expiration time set for the master copy, depending decided to delay the expiration time from libraries, avoiding the main library has not yet reached the binlog will expire and be removed from the library, resulting in a master-slave inconsistent! ! !

Guess you like

Origin www.cnblogs.com/samsui/p/12035496.html