This topic describes how to configure policies that are used to delete binary log files from an ApsaraDB RDS for MySQL instance. Before you configure the policies, you must understand the rules based on which MySQL generates and deletes binary log files.
- Rules to generate binary log files
- In most cases, after the size of a binary log file reaches 500 MB, the RDS instance starts to write data into a new binary log file. This indicates that in theory every binary log file is 500 MB in size. When the RDS instance continues to write data into the new binary log file, the old binary log file is asynchronously uploaded to Alibaba Cloud Object Storage Service (OSS).
- The RDS instance may stop writing data into a binary log file due to reasons such as command execution and system reboot.
- The RDS instance may continue to write data to a binary log file even if the binary log file reaches 500 MB in size. For example, this occurs if the RDS instance is running large transactions.
- Rules to delete binary log files
- The RDS instance stores the binary log files that are generated within the last 18 hours.
- If the storage usage does not exceed 80% of the storage capacity that you purchased, the RDS instance does not delete binary log files that have been uploaded to OSS. It can store binary log files that occupy up to 30% of the storage capacity.
- If the storage usage exceeds 80% of the storage capacity that you purchased, the RDS instance initiates requests to delete binary log files that have been uploaded to OSS. The deletion of binary log files is scheduled by using tasks and may cause latency.
- Log on to the ApsaraDB for RDS console.
- In the top navigation bar, select the region where the target RDS instance resides.
- In the left-side navigation pane, click Backup and Restoration to open the Backup and Restoration page.
- Click the Local Log Settings tab.
- Click Edit. In the Local Binary Log Settings dialog box, configure the following parameters.
Parameter Description Retention Period The retention period of binary log files. Valid values: 0 to 168. Default value: 18. Unit: hours. For example, the default value 18 specifies to store binary log files that are generated within the last 18 hours. If you enable the log backup function, the RDS instance backs up binary log files that are stored longer than 18 hours and then deletes these files. Max Storage Usage The maximum storage usage that is allowed for binary log files. Valid values: 0 to 50. Default value: 30. Unit: %. For example, the default value 30 specifies to delete earlier binary log files when the storage usage exceeds 30%. Retained Binlogs The number of binary log files that can be retained. Valid values: 6 to 100. Default value: 60. If the number of binary log files that are generated exceeds the specified value, the RDS instance deletes earlier binary log files. Protect Available Storage Specifies whether to forcibly delete earlier binary log files. This occurs if the total storage usage exceeds 80% or the available storage space is less than 5 GB. This function is enabled by default.
- Click OK.