MySQL Log Management
Log Classification
The logs of a MySQL instance include three types: binary log (BinLog), slow query log (SlowLog), and error log (ErrorLog).
The binary log (BinLog) records SQL statements that have changed or potentially changed the data, and stores them in binary form.
The slow query log (SlowLog) is a log in which the MySQL instance records all SQL statements that exceed the time threshold set by the long\_query\_time parameter.
The error log (ErrorLog) is a record of the error information encountered by the MySQL instance service process mysqld during startup/shutdown or operation.
Query Logs
MySQL supports querying historical logs and real-time logs through the console. Specific operation: on the instance detail page, select log management, select the log type and query type, and click on query log:
Log Download
Select log management on the details page, and select the log package in the page to package the slow query log (SlowLog) and error log (ErrorLog), and it can be downloaded. High availability instances support downloading logs from both primary and replica nodes.
The slow query log seen in the console is the raw log, and the downloaded slow query log is the log processed by pt-query-digest.
Select backup management on the details page, select Binlog in the page to package the binary log (BinLog), clean up the log, and it can be downloaded and deleted.
Clear Binlog Log
On the "Details" page, select "Backup Management", then select "Binlog Log Settings", and click on "Clear Local Log".
Cleaning the log will first check the cleanable time, and return the start time, end time, and safe time that can be cleaned. The start time is the time of the first Binlog that the instance can clean. For high availability instances, the earliest time of the two nodes will be shown. The end time is the latest time for Binlog cleanup, considering the limit cleanup time for instance to retain two Binlogs, as well as the time for highly available unsynchronized Binlog and the time for slave unsynchronized Binlog. The safe time is the time when Binlog can be safely cleaned without affecting the roll back function of DB. At present, this time is meaningful only when using the Binlog dump function.