This page describes how to configure change data capture (CDC) to stream data from an Amazon RDS for MySQL database to a supported destination , such as BigQuery or Cloud Storage.
Create a parameter group
-
Launch your Amazon RDS Dashboard.
-
In the Navigation Drawer, click Parameter Groups.
-
Click Create Parameter Group. The Create Parameter Grouppage appears.
-
Select the database family that matches your database, provide a name and description for the parameter group.
-
Click Create.
-
Select the checkbox to the left of your newly created parameter group.
-
Under Parameter group actions, click Edit.
-
Use the following table to set the parameters for your group.
-
For binlog-basedreplication:
Parameter Value binlog_format ROWlog_bin_use_v1_row_events 1read_only 0net_read_timeout 3600net_write_timeout 3600wait_timeout 86400 -
For GTID-basedreplication:
ParameterValuebinlog_formatROWlog_bin_use_v1_row_events1read_only0net_read_timeout3600net_write_timeout3600wait_timeout86400expire-logs-days7binlog_row_imageFULLmax_allowed_packet1G(recommended value)log-replica-updates1enforce-gtid-consistencyONgtid_mode
You can only set this parameter toONONafter you setenforce-gtid-consistencytoON. In general,gtid_modecan have the following values:-
OFF -
OFF_PERMISSIVE -
ON_PERMISSIVE -
ON
gtid_modeparameter one step at a time. For example, if the current mode is set toOFF, do the following:- Change the setting to
OFF_PERMISSIVE. - Change the setting to
ON_PERMISSIVE. - Change the setting to
ON.
-
-
-
Click Save 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 in Configure the source database and the read replica .
-
Launch your Amazon RDS Dashboard.
-
In the Navigation Drawer, click Databases.
-
Select the main database instance to which you want Datastream to connect.
-
Expand the Actionsbutton, and then click Create read replica.
-
Configure the read replica, as necessary.
-
Click Create read replica.
Configure the source database and the read replica
If you chose to replicate directly from the main server, configure the source database using the steps that follow.
If you chose to use a read replica, configure both the source database and the read replica using the steps that follow.
-
Launch your Amazon RDS Dashboard.
-
In the Navigation Drawer, click Databases.
-
Select the instance that you want to configure and then click Modify.
-
Go to the Additional configurationsection.
-
Select the parameter group that you created .
-
Set the Backup retention periodto 7 days.
-
Click Continue.
-
Under Scheduling of modifications, select Apply immediately.
Verify that the parameter group is assigned to the database instance
-
Launch your Amazon RDS Dashboard.
-
In the Navigation Drawer, click Databases, and then select your database instance.
-
Click the Configurationstab.
-
Verify that you see the parameter group that you created , and that its status is pending-reboot.
-
Reboot your database instance to complete the configuration. To reboot the instance:
- In the Navigation Drawer, click Instances.
- Select your database instance.
- From the Instance Actionsmenu, select Reboot.
Set the binary log retention period
-
Enter the following MySQL command:
call mysql . rds_set_configuration ( 'binlog retention hours' , 168 );
-
Restart your MySQL server so that the changes you made can take effect.
Create a Datastream user
-
Create a Datastream user:
CREATE USER 'datastream' @ '%' IDENTIFIED BY ' YOUR_PASSWORD ' ;
-
Grant the following privileges to them:
GRANT REPLICATION SLAVE , SELECT , REPLICATION CLIENT ON * . * TO 'datastream' @ '%' ; GRANT EXECUTE ON PROCEDURE mysql . rds_show_configuration TO 'datastream' @ '%' ; FLUSH PRIVILEGES ;
What's next
- Learn more about how Datastream works with MySQL sources .

