All Products
Search
Document Center

ApsaraDB RDS:Manage binary log files

Last Updated:Oct 25, 2024

Binary log files record all changes made to an ApsaraDB RDS for MySQL instance and can be used to build a primary/secondary architecture and track data. This topic describes how to view and delete the binary log files of an ApsaraDB RDS for MySQL instance.

Differences between binary log files and log backup files

Item

Binary log file

Log backup file

Overview

Binary log files can be used to build a primary/secondary architecture and track data.

After you enable the log backup feature for your RDS instance, the binary log files of your RDS instance are uploaded to backup storage in real time. The binary log files in the backup storage are called log backup files. You can use log backup files to restore data to a specific point in time within the backup retention period that you specified. For more information, see Use the log backup feature.

Enabling and disabling

The feature is automatically enabled and cannot be disabled.

You can enable or disable the feature based on your business requirements.

Billing rule

N/A

The log backup feature is provided free of charge, and a free quota on backup storage is provided. If the total size of the data backup files and log backup files of your RDS instance exceeds the free quota, you are charged for the excess backup storage. For more information, see View and manage the size of backup files and Backup storage fees.

Storage capacity

Binary log files consume the storage capacity of your RDS instance.

You can view the storage capacity in the Usage Statistics section of the Basic Information page.

Log backup files do not consume the storage capacity of your RDS instance.

Note

Log backup files are stored in backup storage that is inaccessible. You can view the log size in the Usage Statistics section of the Basic Information page.

Rules for generating binary log files

Binary log files are generated on RDS instances in real time. The rules based on which binary log files are generated vary based on the RDS edition of your RDS instance.

  • RDS Basic Edition, RDS Cluster Edition, or RDS High-availability Edition: When the size of a binary log file exceeds 512 MB or the period of time during which binary log data is being written to a binary log file exceeds 6 hours, a new binary log file is generated.

  • RDS Enterprise Edition: When the size of a binary log file exceeds 512 MB, a new binary log file is generated.

Note

In some scenarios, the size of a binary log file on your RDS instance may be less than 512 MB. This may occur when you execute specific commands or restart your RDS instance. In some scenarios, the size of a binary log file on your RDS instance may be larger than 512 MB. This may occur when you run large transactions on your RDS instance.

View binary log files

You cannot view binary log files in the ApsaraDB RDS console. To view binary log files, you must execute the SHOW BINARY LOGS; statement. For more information, see How do I remotely obtain and parse the binary log file of an ApsaraDB RDS for MySQL instance?

View the total size of binary log files

  1. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.

  2. In the left-side navigation pane, click Monitoring and Alerts. On the Standard Monitoring tab of the page that appears, view the total size of binary log files.

    Note

    By default, the total size of on the primary RDS instance is the same as the size of binary log files on a secondary RDS instance. The sizes may differ due to the following reasons: The secondary RDS instance replicates data from the primary RDS instance at a latency, the binary log files are dumped at a latency, Data Transmission Service (DTS) is migrating data of the RDS instances, or the secondary RDS instance is reading and applying binary logs.

    binlog空间

Delete binary log files

Note
  • After binary log files are deleted, the storage that is occupied by the binary log files is released.

  • After binary log files are deleted from an RDS instance, the size of the log backup files of the RDS instance does not decrease and you can still restore the data of the RDS instance to a specific point in time. Take note that you can restore the data of an RDS instance to a specific point in time only after you enable the log backup feature for the RDS instance.

Configure parameters based on which the system automatically deletes the binary log files of an RDS instance

  1. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.

  2. In the left-side navigation pane, click Backup and Restoration.

  3. On the Backup Strategy tab of the page that appears, click Edit in the Local Log Retention Policy section and configure the following parameters. The system automatically deletes the binary log files of your RDS instance based on the parameter settings.

    Parameter

    Description

    Default value

    System action

    Retention Period

    The maximum retention period of binary log files.

    3 Hours

    If the binary log files whose retention period exceeds the specified retention period are backed up by using the log backup feature, the system automatically deletes the binary log files.

    Maximum Storage Space Usage

    The maximum storage usage of binary log files.

    Note

    Storage usage = (Size of binary log files/Size of storage capacity) × 100%

    30%

    If the storage usage of binary log files exceeds the maximum storage usage, the system automatically deletes earlier binary log files until the storage usage is less than the maximum storage usage.

    Maximum Files to Retain

    The maximum number of binary log files that can be retained.

    60

    If the number of retained binary log files exceeds the maximum number, the system automatically deletes earlier binary log files until the number is less than the maximum number.

    Available Storage Space

    Specifies whether to automatically delete binary log files when the storage usage exceeds 80% or the amount of available storage is less than 5 GB.

    -

    If the storage usage exceeds 80% or the amount of available storage is less than 5 GB, the system automatically deletes earlier binary log files until storage usage is less than 80% and the amount of available storage is greater than 5 GB.

Manually delete the binary log files of an RDS instance

  1. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.

  2. In the left-side navigation pane, click Backup and Restoration.

  3. On the page that appears, click Upload Binlogs. In the message that appears, click OK.

    Note
    • If you perform this operation, all binary log files except the most recent two binary log files are deleted. In this case, deletion latency occurs, and a period of time is required for the deletion to take effect.

    • This operation is not supported for RDS instances that run 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 become faulty or a change tracking task is in progress. In this case, 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 system 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 on the RDS instance.

  4. Optional. Log on to the RDS instance and run the show binary logs; command to view 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. Optional. Go to the Monitoring and Alerts page and view the size of binary log files.日志大小

What to do next

FAQ

  • How do I enable binary logging for an ApsaraDB RDS for MySQL instance.

    By default, binary logging of an ApsaraDB RDS for MySQL instance is enabled and cannot be disabled. For more information, see Manage binary logs.

  • 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 in my database system?

    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 Binlog dump thread dumps the binary log files 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 log records.

  • Why does the system automatically delete a binary log file of my RDS instance immediately after the binary log file is generated?

    The storage usage of the RDS instance may reach 80%, or the amount of available storage on the RDS instance is less than 5 GB. If you set the Available Storage Space parameter in the Local Log Retention Policy dialog box to Enabled, all binary log files are deleted immediately after they are generated. We recommend that you manually increase the storage capacity of the RDS instance or enable the automatic storage expansion feature for the RDS instance. This way, the RDS instance is not locked even if the storage usage reaches 80% or the amount of available storage is less than 5 GB. For more information, see Change instance specifications or Configure automatic storage expansion.