Configure an Amazon RDS MySQL database for CDC

This page describes how to configure change data capture (CDC) tostream data from an Amazon RDS for MySQL database to asupported destination,such as BigQuery or Cloud Storage.

Create a parameter group

  1. Launch your Amazon RDS Dashboard.

  2. In theNavigation Drawer, clickParameter Groups.

  3. ClickCreate Parameter Group. TheCreate Parameter Group page appears.

  4. Select the database family that matches your database, provide a name anddescription for the parameter group.

  5. ClickCreate.

  6. Select the checkbox to the left of your newly created parameter group.

  7. UnderParameter group actions, clickEdit.

  8. Use the following table to set the parameters for your group.

    • Forbinlog-based replication:

      ParameterValue
      binlog_formatROW
      log_bin_use_v1_row_events1
      read_only0
      net_read_timeout3600
      net_write_timeout3600
      wait_timeout86400
    • ForGTID-based replication:

      ParameterValue
      binlog_formatROW
      log_bin_use_v1_row_events1
      read_only0
      net_read_timeout3600
      net_write_timeout3600
      wait_timeout86400
      expire-logs-days7
      binlog_row_imageFULL
      max_allowed_packet1G (recommended value)
      log-replica-updates1
      enforce-gtid-consistencyON
      gtid_mode

      ON

      You can only set thisparameter toON after you setenforce-gtid-consistencytoON. In general,gtid_mode can have the followingvalues:
      • OFF
      • OFF_PERMISSIVE
      • ON_PERMISSIVE
      • ON
      You can only change the values of thegtid_mode parameter onestep at a time. For example, if the current mode is set toOFF,do the following:
      1. Change the setting toOFF_PERMISSIVE.
      2. Change the setting toON_PERMISSIVE.
      3. Change the setting toON.
      For more information, seeMySQL documentation.
  9. ClickSave Changes.

Create a read replica

Although this is an optional step, we highly recommend using a read replica because it significantly decreases the load of replication on your MySQL database.

If you choose to replicate directly from the main server, then proceed to the instructions inConfigure the source database and the read replica.

  1. Launch your Amazon RDS Dashboard.

  2. In theNavigation Drawer, clickDatabases.

  3. Select the main database instance to which you want Datastream toconnect.

  4. Expand theActions button, and then clickCreate read replica.

  5. Configure the read replica, as necessary.

  6. ClickCreate read replica.

Configure the source database and the read replica

If you chose to replicate directly from the main server, configure the sourcedatabase using the steps that follow.

If you chose to use a read replica, configure both the source database and theread replica using the steps that follow.

  1. Launch your Amazon RDS Dashboard.

  2. In theNavigation Drawer, clickDatabases.

  3. Select the instance that you want to configure and then clickModify.

  4. Go to theAdditional configuration section.

  5. Select the parameter group that youcreated.

  6. Set theBackup retention period to7 days.

  7. ClickContinue.

  8. UnderScheduling of modifications, selectApply immediately.

    Wait until the changes to your parameter group are appliedbefore proceeding.

Verify that the parameter group is assigned to the database instance

  1. Launch your Amazon RDS Dashboard.

  2. In theNavigation Drawer, clickDatabases, and then select yourdatabase instance.

  3. Click theConfigurations tab.

  4. Verify that you see the parameter group that youcreated,and that its status ispending-reboot.

  5. Reboot your database instance to complete the configuration. To reboot theinstance:

    1. In theNavigation Drawer, clickInstances.
    2. Select your database instance.
    3. From theInstance Actions menu, selectReboot.
    After you reboot your database instance, its statuschanges to **in-sync**.

Set the binary log retention period

  1. Enter the following MySQL command:

    callmysql.rds_set_configuration('binlog retention hours',168);
    You're entering this command because you want to ensureproper replication by configuring your system to retain binary logs for aminimum of 7 days (or 168 hours).
  2. Restart your MySQL server so that the changes you made can take effect.

Create a Datastream user

  1. Create a Datastream user:

    CREATEUSER'datastream'@'%'IDENTIFIEDBY'YOUR_PASSWORD';
  2. Grant the following privileges to them:

    GRANTREPLICATIONSLAVE,SELECT,REPLICATIONCLIENTON*.*TO'datastream'@'%';GRANTEXECUTEONPROCEDUREmysql.rds_show_configurationTO'datastream'@'%';FLUSHPRIVILEGES;

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.