MYSQL database configuration binlog retention time

Scenario: As the amount of data written is too large, the binlog file occupies more and more. The binlog needs to be cleaned up.
Suggestion: Do not use reset master to clean up the binlog. If synchronization is done, the synchronization will fail.
1. Enter mysql Database, check the retention time of the default configuration
mysql> show variables like "%expire_logs_days%";
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days | 30 |
+-------------- ----+-------+

1 row in set (0.02 sec)

2. Adjust the retention time (this operation is a temporary configuration, the default configuration will be restored after restarting mysql)
mysql>set global expire_logs_days=7;

3. Modify the configuration file to make the configuration take effect permanently
vim /etc/my.cnf
[mysqld]
expire_logs_days=7
· Note: 0- means never expire; the unit is days.

4. Restart the mysql service
#systemctl restart mysqld

Guess you like

Origin blog.51cto.com/14483703/2545426