mysql correctly cleans up binlog logs Preface: The binlog in MySQL records the changes in the data in the database, which facilitates the time-based and location-based recovery of the data. However, the binlog will also grow larger and take up a lot of disk space. Therefore, it is necessary to use the correct and safe method to clean up some useless logs. [Method 1] Manually clean up binlog Preparation before cleaning: ① Check which binlog file the master and slave are using show master status\G show slave status\G ② Before deleting the binlog log, back up the binlog log first, just in case Start deleting binlog: purge master logs before'2016-09-01 17:20:00'; //Delete the binlog log files in the log index before the specified date or purge master logs to'mysql-bin.000022'; //Delete the binlog log file in the log index of the specified log file Notice: The time and file name must not be written incorrectly, especially the year in the time and the serial number in the file name, to prevent the binlog in use from being accidentally deleted! ! ! Never delete a binlog that is in use! ! ! Using this syntax will delete the corresponding files and the corresponding paths in mysql-bin.index. [Method 2] Set the binlog expiration time to enable the system to automatically delete the binlog file mysql> show variables like 'expire_logs_days'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | expire_logs_days | 0 | +------------------+-------+ mysql> set global expire_logs_days = 30; #Set the number of days for binlog to expire Notice: The expiration time should be set appropriately. For master-slave replication, the expiration time should be determined based on the delay of the slave database to avoid the master database binlog being deleted due to expiration before being transferred to the slave database, resulting in inconsistency between the master and the slave! ! ! Thank you for reading, I hope it can help you, thank you for your support of this site! You may also be interested in:
|
<<: How to generate Vue user interface by dragging and dropping
>>: Docker container introduction
Preface MySQL supports many types of tables (i.e....
CSS style rule syntax style is the basic unit of ...
Prepare: MySQL 8.0 Windows zip package download a...
serializable serialization (no problem) Transacti...
Table of contents 1. Basic Concepts ACID 3.AutoCo...
Based on daily development experience and relevan...
This article shares the installation and configur...
When the table header is fixed, it needs to be di...
Table of contents 1. Open WeChat Pay 1.1 Affiliat...
Preface The original project was placed on the pu...
This article shares the specific code of the jQue...
This article shares the specific code of JS to ac...
1. Introduction When we are writing a page, we so...
Table of contents 1. Create a watermark Js file 2...
This article shares the specific code for Vue to ...