This topic describes how to configure a policy that allows an ApsaraDB RDS for MySQL instance to automatically upload its binary log files to an Object Storage Service (OSS) bucket. This topic also describes how to manually upload these binary log files. The operations in this topic allow you to reduce the storage usage of your RDS instance.

Background information

Before you upload the binary log files of your RDS instance to an OSS bucket, you must understand the rules based on which MySQL generates and deletes binary log files.

Note The binary log files of your RDS instance are uploaded to an OSS bucket. This OSS bucket is used to store the backup files of the instance. The fee for this OSS bucket is not included in your OSS resource plan.
  • Default rules based on which MySQL generates binary log files
    • In most cases, when the size of a binary log file reaches 500 MB, your RDS instance starts to write data into a new binary log file. This indicates that the size of every binary log file is 500 MB.
    • Your RDS instance may stop writing data into a binary log file before the size of the file reaches 500 MB. For example, this can occur due to some commands or a restart.
    • Your RDS instance may continue writing data into a binary log file even after the size of the file reaches 500 MB. For example, this can occur due to large transactions.
  • Default rules based on which MySQL deletes binary log files

    If one or more of the following rules are triggered, your RDS instance starts to upload binary log files to the specified OSS bucket. Then, your RDS instance starts to delete binary log files. The deletion process starts from the earliest binary log file. When no rules are triggered, the deletion process is stopped. Binary log files are uploaded by using tasks. These tasks are scheduled in Data Transmission Service (DTS) based on specified rules. In addition, these tasks are executed at specific latencies.

    • Your RDS instance can store only the binary log files that are generated over the last 18 hours.
    • Your RDS instance can store a maximum of 60 binary log files.
    • The storage space that is occupied by the binary log files on your RDS instance cannot exceed 30% of the purchased storage capacity.
    • The storage usage of your RDS instance cannot exceed 80%, or the remaining storage space cannot be less than 5 GB.
    Note If one or more of the preceding rules are triggered but your RDS instance does not upload or delete binary log files, your database client may encounter errors. This may also occur if the tasks that are scheduled in DTS to upload binary log files are blocked. In these cases, you must terminate the blocked tasks. You can view the IDs of the threads that are used to run the tasks. The IDs of the threads are provided on the Error Logs tab of the Logs page in the ApsaraDB RDS console.
    [Warning] file /home/mysql/data3001/mysql/mysql-bin.069435 was not purged because it was being readby thread number 17126285

Configure a policy that is used to upload binary log files

  1. Go to the Backup and Restoration page.
    1. Log on to the ApsaraDB for RDS console. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where your RDS instance resides.
      选择地域
    2. Find your RDS instance and click its ID. In the left-side navigation pane, click Backup and Restoration.
  2. Click the Local Log Settings tab.
  3. Click Edit. In the dialog box that appears, configure the following parameters.
    Parameter Description
    Retention Period The number of hours for which you want to retain binary log files. Valid values: 0 to 168. Default value: 18. For example, the value 18 specifies to retain the binary log files that are generated over the last 18 hours. In this case, your RDS instance backs up the binary log files that were generated 18 hours ago. After these binary log files are backed up, your RDS instance 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 value 30 specifies to delete binary log files when the storage usage exceeds 30%. The deletion process starts from the earliest binary log file.
    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 value of this parameter, your RDS instance starts to delete binary log files. The deletion process starts from the earliest binary log file.
    Protect Available Storage The status of the feature that is used to forcibly delete binary log files. By default, this feature is enabled. If the overall storage usage exceeds 80% or the available storage space is less than 5 GB, your RDS instance starts to delete binary log files. The deletion process starts from the earliest binary log file. When the overall storage usage falls below 80% and the available storage space exceeds 5 GB, your RDS instance stops deleting binary log files.
  4. Click OK.

Upload binary log files

You can manually upload the binary log files of your RDS instance. Your RDS instance deletes all the binary log files that are uploaded to the specified OSS bucket. Binary log files are uploaded by using tasks. These tasks are scheduled in DTS based on specified rules. In addition, these tasks are executed at specific latencies.

Note If your RDS instance runs the Basic Edition, you cannot upload binary log files to the specified OSS bucket.
  1. Go to the Backup and Restoration page.
    1. Log on to the ApsaraDB for RDS console. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where your RDS instance resides.
      选择地域
    2. Find your RDS instance and click its ID. In the left-side navigation pane, click Backup and Restoration.
  2. Click Upload Binlogs. In the message that appears, click OK.

Related operations

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