This topic describes how to delete the binary log files of an ApsaraDB RDS for MySQL instance. You can configure rules based on which ApsaraDB RDS automatically deletes binary log files. You can also manually delete binary log files.

Binary log files are generated on your RDS instance in real time. The rules based on which binary log files are generated varies based on the RDS edition:
  • RDS Basic Edition or RDS High-availability Edition: When the size of a binary log file exceeds 512 MB512 MB or the length of time during which binary log data continues to be written to a binary log file exceeds 6 hours, a new binary log file is generated.
  • RDS Enterprise Edition: If the size of a binary log file exceeds 512 MB,512 MB a new binary log file is generated.
When binary log files are deleted from an RDS instance, the storage that is consumed for the binary log files is released.
Note The deletion of binary log files does not reduce the size of log backup files or affect the restoration of data to a specific point in time. You can restore data to a specific point in time only after you enable the log backup feature.

Procedure

To configure the rules based on which ApsaraDB RDS automatically deletes the binary log files of an RDS instance, perform the following steps:
  1. Visit the RDS instance list, select a region above, and click the target instance ID.
  2. In the left-side navigation pane, click Backup and Restoration.
  3. On the Backup Settings tab, click Edit in the Local Log Backup Settings section to configure the rules.
    • Rule 1: ApsaraDB RDS deletes the binary log files that are retained for more than the specified retention period. This retention period is specified by the Retention Period parameter. The default retention period is 18 hours.
    • Rule 2: If one of the following conditions is met, ApsaraDB RDS deletes earlier binary log files until the condition is not met.
      • The storage usage that is calculated based on the following formula exceeds the threshold that is specified by the Max Storage Usage parameter: Storage usage = (Size of binary log files/Size of storage capacity) × 100%. The default threshold is 30%.
      • The number of binary log files exceeds the number that is specified by the Retained Files parameter. The default number is 60.
      • The storage usage exceeds 80% or the amount of available storage is less than 5 GB. Make sure that the Protect Available Storage option is selected.

To manually delete the binary log files of an RDS instance, perform the following steps:

  1. Visit the RDS instance list, select a region above, and click the target instance ID.
  2. In the left-side navigation pane, click Backup and Restoration.
  3. Click Upload Binlogs. Then, click OK.

    This operation deletes all binary log files except the most recent two binary log files. Examples:

    • If the RDS instance contains three binary log files: mysql-bin.000192, mysql-bin.000193, and mysql-bin.000194, this operation deletes only the mysql-bin.000192 binary log file.
    • If the RDS instance contains two binary log files, this operation does not delete the binary log files.
    Note
    • ApsaraDB RDS deletes binary log files at a latency.
    • This operation is not supported for RDS instances that run the RDS Basic Edition.
    • If binary log files cannot be deleted and the following warning is displayed on the Error Logs tab of the Logs page, the database client may encounter errors, or a change tracking task is in progress. You must stop the task before you can delete the binary log files.
      [Warning] file /home/mysql/data3001/mysql/mysql-bin.069435 was not purged because it was being readby thread number 17126285
    • If you use the Upload Binlogs feature, the RDS instance uploads binary log files to the specified Object Storage Service (OSS) bucket. The retention period of binary log files that are stored as objects in the OSS bucket is the same as the log backup retention period that you specify for the RDS instance.
  4. Log on to the RDS instance and run the show binary logs; command to check the binary log files of the RDS instance. For more information, see Use DMS to log on to an ApsaraDB RDS for MySQL instance.
  5. Check the size of binary log files on the Monitoring and Alerts page. Check the binary log files

Related operations

Operation Description
PurgeDBInstanceLog Deletes the binary log files of an ApsaraDB RDS instance.

FAQ

  • Why is the size of binary log files on the primary RDS instance different from the size of binary log files on the secondary RDS instance?
    By default, the size of binary log files on the primary RDS instance is the same as the size of binary log files on the secondary RDS instance. The two sizes may be different due to the following reasons:
    • The primary RDS instance replicates data to the secondary RDS instance at a latency, the binary log files are dumped by the Binlog dump thread at a latency, or Data Transmission Service (DTS) is migrating data from or to the primary RDS instance.
    • The secondary RDS instance is reading and applying logs.