giip
SES Proposal
Aurora MySQLbinlogレプリケーションCDCパラメータAurora

How to Check and Configure binlog Retention in Aurora MySQL

公開日 2026-08-13 · 更新日 2026-08-13 · 最終検証日 2026-08-13

結論

Check Aurora MySQL's binlog retention time with `CALL mysql.rds_show_configuration;` and set it with `CALL mysql.rds_set_configuration('binlog retention hours', 24);`. The unit is hours; if it is `NULL` or 0, RDS purges binlogs early once it judges them unnecessary. For a setup where a consumer such as DMS CDC reads the binlog, set it long enough for the consumer to catch up even after an outage. Also check whether `binlog_format` is `ROW`.

この文書の適用条件

対象製品Aurora MySQL (MySQL-compatible edition)
確認バージョンAurora MySQL 2.x (MySQL 5.7-compatible) / 3.x (MySQL 8.0-compatible). Whether `SHOW MASTER STATUS` is available varies by version — verify
適用環境Amazon Aurora (AWS)
必要権限`mysql.rds_set_configuration` requires RDS master-user-equivalent privileges. `SHOW BINARY LOGS` requires the `REPLICATION CLIENT` privilege
実行影響No impact from read-only checks. Changing the retention time is a configuration change; changing `binlog_format` involves a restart; `PURGE BINARY LOGS` deletes logs
再起動Not required to change the retention time. Changing `binlog_format` requires restarting the writer instance
最終検証日2026-08-13

そのまま実行できるコマンド

Check the current binlog retention time参照のみ
対象
Aurora MySQL 2.x / 3.x
権限
Privilege to execute stored procedures (typically the master user)
変更作業
None (read-only)
Production実行
Possible
-- 対象: Aurora MySQL 2.x / 3.x
-- 権限: mysql スキーマのストアドプロシージャ実行権限(通常はマスターユーザー)
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
CALL mysql.rds_show_configuration;

The row where `name` is `binlog retention hours` is the retention time. A `NULL` value means no explicit setting, and RDS purges binlogs early once it judges them unnecessary. The same result set also includes other RDS settings.

Check the current binlog settings参照のみ
対象
Aurora MySQL 2.x / 3.x
権限
Connection privilege (read global variables)
変更作業
None (read-only)
Production実行
Possible
-- 対象: Aurora MySQL 2.x / 3.x
-- 権限: 接続権限(グローバル変数の参照のみ)
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
SELECT
    @@global.log_bin           AS log_bin_enabled,
    @@global.binlog_format     AS binlog_format,
    @@global.binlog_row_image  AS binlog_row_image,
    @@global.binlog_checksum   AS binlog_checksum;

In Aurora MySQL, setting `binlog_format` to anything other than `OFF` enables the binlog. DMS CDC and typical replication assume `ROW`. If `binlog_row_image` is `MINIMAL`, values for columns other than the changed ones are not recorded, which can leave out information the CDC side needs.

Check the existing binlog files and their positions参照のみ
対象
Aurora MySQL 2.x / 3.x (writer instance)
権限
`REPLICATION CLIENT` privilege
変更作業
None (read-only)
Production実行
Possible
-- 対象: Aurora MySQL 2.x / 3.x(ライターインスタンス)
-- 権限: REPLICATION CLIENT 権限
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能

-- 1) 現存するbinlogファイルとサイズ
SHOW BINARY LOGS;

-- 2) 現在の書き込み位置(Aurora MySQL 3.x の一部バージョンでは
--    SHOW BINARY LOG STATUS に置き換えられているため、エラーになる場合はそちらを使う)
SHOW MASTER STATUS;

The total size in `SHOW BINARY LOGS` grows or shrinks with the retention setting. File names follow the `mysql-bin-changelog.NNNNNN` format on Aurora. `SHOW MASTER STATUS` has been renamed in newer MySQL 8.0-series versions, so check whether it works in your own environment (unverified).

Set the binlog retention time
対象
Aurora MySQL 2.x / 3.x
権限
RDS master-user-equivalent privileges (cannot be run by a regular application user)
変更作業
Yes (changes the binlog retention policy)
Production実行
Possible, but estimate the storage increase beforehand
-- 対象: Aurora MySQL 2.x / 3.x
-- 権限: RDSのマスターユーザー相当(一般ユーザーではアクセス拒否になる)
-- 変更作業: あり(binlog の保持時間ポリシーを変更する)
-- Production 実行: 可能。ただしストレージ消費が増えるため事前に見積もること

-- 保持時間は「時間」単位で指定する(例: 24時間)
CALL mysql.rds_set_configuration('binlog retention hours', 24);

-- 設定後の値を確認する
CALL mysql.rds_show_configuration;

-- 明示設定を解除して既定の挙動(早期削除)に戻す場合
-- CALL mysql.rds_set_configuration('binlog retention hours', NULL);

The second argument is a number of hours, not days. Setting it to `NULL` clears the explicit setting and returns to RDS deleting binlogs once it judges them unnecessary. Right after shortening the setting, a CDC consumer that hasn't finished reading yet may be unable to catch up, so check the consumer's lag before shortening it.

Change binlog_format to ROW (requires a restart)
対象
Aurora MySQL (DB cluster parameter group)
権限
IAM: `rds:ModifyDBClusterParameterGroup`, `rds:RebootDBInstance`
変更作業
Yes (cluster parameter change + writer instance restart)
Production実行
Not possible due to the restart involved. Plan execution during a maintenance window
# 対象: Aurora MySQL(DBクラスターパラメータグループ)
# 権限: IAM rds:ModifyDBClusterParameterGroup, rds:RebootDBInstance
# 変更作業: あり(クラスターパラメータ変更 + ライターインスタンス再起動)
# Production 実行: 不可(再起動を伴うためメンテナンス時間帯に計画実行)

# 1) 現在値と反映方法を確認する
aws rds describe-db-cluster-parameters \
  --db-cluster-parameter-group-name example-aurora-mysql-cluster-params \
  --query "Parameters[?ParameterName=='binlog_format' || ParameterName=='binlog_row_image'].{Name:ParameterName,Value:ParameterValue,Apply:ApplyType}" \
  --output table

# 2) binlog_format を ROW に変更する(クラスター単位のパラメータ)
aws rds modify-db-cluster-parameter-group \
  --db-cluster-parameter-group-name example-aurora-mysql-cluster-params \
  --parameters '[
    {"ParameterName":"binlog_format","ParameterValue":"ROW","ApplyMethod":"pending-reboot"}
  ]'

# 3) ライターインスタンスを再起動して反映する(接続断が発生する)
aws rds reboot-db-instance --db-instance-identifier example-aurora-instance

`binlog_format` is a setting on the DB cluster parameter group side; you won't find it by looking in the instance-level DB parameter group. Applying it requires a restart and causes a connection drop. Enabling the binlog adds log-generation load to writes, but the magnitude depends on the workload, so measure it in a test environment beforehand (this article does not give a figure).

Manually delete old binlogs (last resort)
対象
Aurora MySQL 2.x / 3.x (writer instance)
権限
`BINLOG_ADMIN` on MySQL 8.0-compatible, `SUPER`-equivalent on 5.7-compatible. The master user on RDS
変更作業
Yes (deletes binlog files; irreversible)
Production実行
Not allowed as a rule. Only after checking every consumer's read position
-- 対象: Aurora MySQL 2.x / 3.x(ライターインスタンス)
-- 権限: MySQL 8.0互換は BINLOG_ADMIN、5.7互換は SUPER 相当(RDSではマスターユーザー)
-- 変更作業: あり(binlog ファイルを削除する。削除したログは復元できない)
-- Production 実行: 原則不可。全ての消費側の読み取り位置を確認してからのみ実施する

-- 1) 先に消費側(レプリカ・DMS・CDC)がどこまで読んでいるかを確認する
SHOW BINARY LOGS;

-- 2) 指定ファイルより前のbinlogを削除する
PURGE BINARY LOGS TO 'mysql-bin-changelog.000123';

-- 3) 日時指定で削除する場合
-- PURGE BINARY LOGS BEFORE '2026-08-01 00:00:00';

Deleting a file that a consumer hasn't finished reading makes replication or CDC unrecoverable, requiring a restart from the initial load. On RDS / Aurora, binlog lifetime should in principle be managed via `binlog retention hours`; treat manual deletion only as a last resort when storage is critically short and there is no other option.

結果の読み方

意味確認するポイント
name (rds_show_configuration)Setting nameLook for the `binlog retention hours` row
value (rds_show_configuration)Setting value (hours)If `NULL`, no explicit setting. Is it longer than the maximum acceptable outage time for CDC consumers?
description (rds_show_configuration)Description of the settingConfirms that the unit is hours
Log_name (SHOW BINARY LOGS)binlog file nameThe `mysql-bin-changelog.NNNNNN` format on Aurora. The oldest file marks the lower bound of retention
File_size (SHOW BINARY LOGS)File size (bytes)The total is the storage consumption. Estimate the total before extending the retention time
binlog_formatbinlog recording format`ROW` is required for DMS CDC and typical replication
binlog_row_imageRange of columns recorded in ROW formatWith `MINIMAL`, the CDC side may lack needed columns

こういう状況で使います

  • A DMS CDC task stopped with an error along the lines of "binlog not found"
  • An external replica was paused and then resumed, but it could not catch up and errored out
  • After enabling the binlog, the cluster's storage usage keeps increasing
  • Running `CALL mysql.rds_set_configuration(...)` resulted in access denied
  • A DMS endpoint test shows a warning related to binlog settings

考えられる原因(可能性の高い順)

  1. 01

    The retention time has no explicit setting

    If `binlog retention hours` is `NULL`, RDS purges binlogs early once it judges them unnecessary. If a CDC consumer pauses, the binlog it needs upon resuming may already be gone.

  2. 02

    The retention time is shorter than the consumer's downtime

    If the retention time is shorter than the time a consumer (a DMS task, an external replica) is down for maintenance or due to a failure, it cannot catch up on resume. The setting needs to be derived by working backward from the acceptable downtime.

  3. 03

    `binlog_format` is not set to `ROW`

    With `STATEMENT` or `MIXED`, the row-level change details that CDC needs cannot be obtained. On Aurora, this is configured in the cluster parameter group.

  4. 04

    The executing user lacks RDS master-user-equivalent privileges

    `mysql.rds_set_configuration` is a stored procedure provided by RDS, and running it requires master-user-equivalent privileges. A regular application user will get access denied.

  5. 05

    A manual `PURGE BINARY LOGS` deleted logs that were still needed

    Deleting a file that a consumer hasn't read yet makes recovery impossible. This is sometimes run as a stopgap when storage is tight and the problem only surfaces later.

  6. 06

    A failover switched the write target

    When the writer switches, how the consumer handles continuity of binlog file names and positions becomes an issue. Check the CDC side's resume method.

確認手順

  1. 1

    Check the current retention time

    参照のみ

    Run `CALL mysql.rds_show_configuration;` and check the value of `binlog retention hours`. This is read-only and safe.

  2. 2

    Check whether the binlog is enabled and in ROW format

    参照のみ

    Check `@@global.log_bin` and `@@global.binlog_format`. Also check `binlog_row_image`.

  3. 3

    Check the range and total size of existing binlogs

    参照のみ

    Use `SHOW BINARY LOGS` to see the oldest file and the total size. This can also be used to estimate before extending the retention time.

  4. 4

    Check the consumer's read position and lag

    参照のみ

    For DMS, check the task's CDC lag metric; for an external replica, check the replica's status to see how far it has read.

  5. 5

    Check the storage usage trend in CloudWatch

    参照のみ

    Estimate the increase from extending the retention time based on the actual trend.

  6. 6

    Check the executing user's privileges

    参照のみ

    Use `SHOW GRANTS;` to check whether the user can run `mysql.rds_set_configuration`.

対応方法

すぐに実施できる低リスクの対応

  • Set the retention time as the master user

    If a regular user gets a privilege error, run it as the RDS master user. Changing the executing user is safer than granting broad privileges to a regular user.

  • Decide the needed retention time from the consumer's acceptable downtime

    参照のみ

    Add up "how many hours it could be down for maintenance" and "how many hours recovery from a failure could take," and set a value longer than that.

事前検討が必要な変更

  • Add the binlog's storage consumption to what you monitor

    参照のみ

    Extending the retention time makes the binlog consume that much more storage. Periodically check the total size in `SHOW BINARY LOGS` and the cluster's storage usage.

  • Monitor the lag of CDC consumers

    参照のみ

    Setting up an alert as lag approaches the retention time lets you notice before the binlog disappears and recovery becomes impossible.

再起動・サービス影響を伴う変更

  • Change `binlog_format` to `ROW`

    Change it in the cluster parameter group and restart the writer instance. Since this causes a connection drop, a planned outage is required.

  • Delete old logs with `PURGE BINARY LOGS`

    Deleted logs cannot be restored. Only do this as a last resort, after checking every consumer's read position.

  • Re-establish CDC

    専門家レビュー必須

    If the binlog is gone and cannot be caught up on, it means starting over from the initial load. Decide the duration and cutover plan first.

!注意事項

  • The unit of `binlog retention hours` is hours. Setting a small value thinking it was days will leave CDC unable to catch up.
  • The longer the retention time, the more storage the binlog consumes. Estimate both the required length and the consumption before setting it.
  • `PURGE BINARY LOGS` cannot restore deleted logs. Do not run it without checking the read position of every consumer.
  • Changing `binlog_format` involves restarting the writer instance. It cannot be applied without downtime.
  • `mysql.rds_set_configuration` requires master-user-equivalent privileges. Avoid granting broad privileges to an application user just to avoid the permission error.
  • Enabling the binlog adds extra processing on the write side. Since the magnitude depends on the workload, this article does not give a figure — measure it in a test environment.

バージョン・環境による違い

Aurora MySQL 2.x (MySQL 5.7-compatible)Running `PURGE BINARY LOGS` requires `SUPER`-equivalent privileges. `SHOW MASTER STATUS` works as-is.
Aurora MySQL 3.x (MySQL 8.0-compatible)Binlog operation privileges are split into dynamic privileges such as `BINLOG_ADMIN`. `SHOW MASTER STATUS` may have been renamed in newer versions, so check whether it works in your own environment (unverified).
Distinguishing cluster parameters from instance parameters`binlog_format` lives in the DB cluster parameter group. You cannot configure it by looking in the instance-level DB parameter group.

これで解決しない場合に確認すること

  • Check how the CDC consumer persists its resume position

    Check where DMS or a replica stores its read position and how it resumes after a failover.

  • Check the cluster's storage usage trend

    Isolate the growth factor including not just the binlog but also temporary space and snapshots.

  • Sort out the relationship with the backup retention period

    Binlog retention and backup retention are separate settings. Clarify which one covers which recovery requirement.

  • Check how the master user is managed

    Without a defined procedure for storing and using the master user credentials, you may not be able to change settings when needed.

  • Build a list of consumers that read the binlog

    Identifying what depends on the binlog — DMS, external replicas, change-notification mechanisms, etc. — speeds up decisions about the retention time.

この文書の根拠と限界

製品の公式ドキュメントに基づく説明

Based on the Amazon RDS / Aurora administrative stored procedures `mysql.rds_show_configuration` / `mysql.rds_set_configuration`, MySQL's binary-log-related system variables (`log_bin`, `binlog_format`, `binlog_row_image`), the public specifications of `SHOW BINARY LOGS` / `PURGE BINARY LOGS`, and the public specifications of Aurora's DB cluster parameter groups. Recommended retention values and the performance impact of enabling the binlog are not stated because they are environment-dependent.

よくある質問

Where can I check the binlog retention time?

Run `CALL mysql.rds_show_configuration;` and look at the `binlog retention hours` row. If the value is `NULL`, there is no explicit setting, and binlogs are deleted as soon as RDS judges them unnecessary.

Why does rds_set_configuration give a permission error?

`mysql.rds_set_configuration` is an administrative stored procedure provided by RDS, and running it requires master-user-equivalent privileges. A regular application user will get access denied. Run it as the master user rather than adding privileges to a regular user.

Can this be run in production?

The read-only checks (`rds_show_configuration`, `SHOW BINARY LOGS`, reading global variables) can be run in production. Changing the retention time increases storage consumption and needs an estimate first; changing `binlog_format` involves a restart and needs a planned outage. As a rule, do not run `PURGE BINARY LOGS` in production.

How long should the retention time be set to?

Rather than a generic recommended value, derive it from the acceptable downtime of consumers. Estimate "the maximum time it could take to recover after CDC stops" and set a value comfortably longer than that. The longer it is, the more storage it consumes.

Is a restart required to change binlog_format?

Yes. `binlog_format` is a DB cluster parameter group setting, and applying it requires restarting the writer instance. Since this causes a connection drop, carry it out during a maintenance window.

How should the results be interpreted?

If `binlog retention hours` is shorter than the consumer's maximum downtime, the setting is insufficient. If the timestamp of the oldest file in `SHOW BINARY LOGS` is newer than the consumer's read position, it has already fallen too far behind to catch up. In that case, a setting change will not fix it — it requires starting over from the initial load.

この文書がカバーする質問

  • Getting a permission error on rds_set_configuration
  • DMS CDC says it cannot find the binlog
  • Want to enable the binlog in Aurora MySQL
  • The binlog is putting pressure on storage

リスク表示の意味

  • 参照のみデータと設定を変更しません。
  • 影響は限定的ですが、権限と負荷の確認が必要です。
  • 性能・ロック・コストに影響する可能性があります。
  • 障害・データ損失・復旧作業が発生する可能性があります。
  • 専門家レビュー必須本番適用前に別途レビューが必須です。

GIIPの対応範囲

binlog retention tends to become a "set it once and forget it" setting, but in practice its appropriateness changes every time the CDC consumer configuration changes. GIIP tracks the retention setting, the total size of existing binlogs, and the CDC-side lag on the same screen, and notifies as soon as the lag approaches the retention time. Irreversible operations such as deleting binlogs or changing `binlog_format` are excluded from automation and are designed to always require human approval.

執筆・技術検証

GIIP プロダクション運用チーム

大規模Webサービス、SQL Server、Oracle、AWS、Azureの設計・移行・運用に約30年従事。x12largeクラスのAWS RDS for SQL Server環境12セット、約12万テーブルのOracle環境、約3TBのTiDBからAurora MySQLへの移行を経験。現在も複数のクラウドデータベースと約30のWebサービスを、AIエージェントと人間の専門家が継続的に監視・運用しています。

関連するナレッジ

関連サービス

Request a review of binlog retention and the CDC setup

同じ確認を複数の環境で継続する必要がある場合は、運用体制ごと相談できます。

Request a review of binlog retention and the CDC setup

ナレッジベース一覧へ