Help Center/ Relational Database Service/ User Guide/ Working with RDS for MySQL/ Data Backups/ Clearing Binlogs/ Setting a Local Retention Period for RDS for MySQL Binlogs
Updated on 2024-10-14 GMT+08:00

Setting a Local Retention Period for RDS for MySQL Binlogs

Scenarios

RDS for MySQL deletes local binlogs after they are backed up to OBS. You can set the local retention period for binlogs as required.

Binary logging is enabled for RDS by default and uses row-based logging.

On the RDS console, you can set the binlog retention period only for the primary instance. The binlog retention period for read replicas is the same as that of the primary instance.

Binlogs can be retained from 0 to 168 (7x24) hours locally.

If the retention period is set to 0, the binlogs of your DB instance will be deleted once they are synchronized to the standby instance and read replicas and successfully backed up to OBS. If the retention period is set to a value greater than 0, for example, 1 day, the binlogs will be retained for one day after they are synchronized to the standby instance and read replicas from the primary instance and successfully backed up to OBS. After the retention period expires, the binlogs will be automatically deleted. For details about how to view binlogs, see Downloading a Binlog Backup File.

Precautions

The binlog retention period is displayed in hour on the console. However, the values of expire_logs_days (MySQL 5.7) and binlog_expire_logs_seconds (MySQL 8.0) are displayed in day when you query the binlog retention period by running a command, which cannot be used as a reference. To check how long the binlogs can be retained, view the binlog retention period on the console.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region.
  3. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the target instance name.
  5. In the navigation pane on the left, choose Backups & Restorations. On the Binlog Backups page, click Set Binlog Retention Period.
  6. In the displayed dialog box, set the local retention period and click OK.

    Figure 1 Setting the binlog retention period

    When binlogs are deleted depends on the local retention period you configure on the console.