本分步指南介绍如何配置 Amazon Aurora MySQL,以便通过 MySQL ClickPipe 将数据复制到 ClickHouse Cloud。有关 MySQL CDC (变更数据捕获) 的常见问题,请参阅 MySQL 常见问题页面。
启用二进制日志保留
二进制日志是一组日志文件,其中记录了对 MySQL 服务器实例所做的数据修改;而复制功能需要这些二进制日志文件。要在 Aurora MySQL 中配置二进制日志保留,您必须先启用二进制日志记录,然后增加 binlog 保留时间间隔。
通过自动备份启用二进制日志记录
自动备份功能决定 MySQL 是否启用二进制日志记录。您可以在 RDS 控制台中依次进入 Modify > Additional configuration > Backup,然后选中 Enable automated backups 复选框 (如果尚未选中) ,为实例配置自动备份。

我们建议根据复制用例,将 Backup retention period 设置为合理且较长的值。
增加 binlog 保留时间间隔
默认情况下,Aurora MySQL 会尽快清除 binlog (即 延迟清除) 。我们建议将 binlog 保留时间增加到至少 72 小时,以确保在故障情况下,复制所需的 binlog 文件仍然可用。要设置 binlog 保留时间 (binlog retention hours) ,请使用 mysql.rds_set_configuration 过程:
mysql=> call mysql.rds_set_configuration('binlog retention hours', 72);如果未设置此配置,或将其间隔设置得过短,可能会导致二进制日志出现间断,从而影响 ClickPipes 恢复复制的能力。
配置 binlog 设置
在 RDS 控制台中点击你的 MySQL 实例,然后进入 Configuration 选项卡,即可找到参数组。

点击参数组链接,进入其详情页。你应该会在右上角看到一个 Edit 按钮。

以下参数需要按如下方式设置:
- 将
binlog_format设为ROW。

- 将
binlog_row_metadata设为FULL。

- 将
binlog_row_image设为FULL。

然后,点击右上角的 Save Changes。你可能需要重启实例,更改才能生效——判断方法是:如果你在 Aurora 实例的 Configuration 选项卡中看到参数组链接旁显示 Pending reboot,就说明需要重启。
启用 GTID 模式 (推荐)
全局事务标识符 (GTID) 是 MySQL 为每个已提交事务分配的唯一 ID。它们可简化 binlog 复制,并使故障排查更加直接。我们建议启用 GTID 模式,以便 MySQL ClickPipe 使用基于 GTID 的复制。
Amazon Aurora MySQL v2 (MySQL 5.7) 和 v3 (MySQL 8.0) 以及 Aurora Serverless v2 均支持基于 GTID 的复制。要为 Aurora MySQL 实例启用 GTID 模式,请按以下步骤操作:
- 在 RDS 控制台中,点击你的 MySQL 实例。
- 点击 Configuration 选项卡。
- 点击参数组链接。
- 点击右上角的 Edit 按钮。
- 将
enforce_gtid_consistency设置为ON。 - 将
gtid-mode设置为ON。 - 点击右上角的 Save Changes。
- 重启实例,使更改生效。

配置数据库用户
以管理员用户身份连接到您的 Aurora MySQL 实例,并执行以下命令:
-
为 ClickPipes 创建一个专用用户:
CREATE USER 'clickpipes_user'@'%' IDENTIFIED BY 'some-password'; -
授予 schema 权限。以下示例展示了
mysql数据库的权限。对于您要复制的每个数据库和主机,都需重复执行这些命令:GRANT SELECT ON `mysql`.* TO 'clickpipes_user'@'host'; -
向该用户授予复制权限:
GRANT REPLICATION CLIENT ON *.* TO 'clickpipes_user'@'%'; GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%';
使用 IAM 身份验证 (可选)
Instead of a password, you can authenticate the ClickPipes user with an AWS IAM role. This lets ClickPipes connect to your Amazon Aurora cluster without storing database credentials.
Enable IAM authentication
- Log in to your AWS account and go to the Aurora cluster you want to configure.
- Click Modify.
- Scroll to the Database authentication section.
- Select Password and IAM database authentication.
- Click Continue.
- Review the changes and select Apply immediately.
Create the ClickPipes user
Create the ClickPipes user with IAM authentication enabled, then grant it the same schema and replication privileges shown above:
CREATE USER 'clickpipes_iam_user' IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS';Obtain the ClickHouse service IAM role ARN
- Log in to your ClickHouse Cloud account.
- Select the ClickHouse service you want to connect.
- Select the Settings tab.
- Scroll to the Network security information section at the bottom of the page.
- Copy the service's Service role ID (IAM) value, shown below.

This value is your {ClickHouse_IAM_ARN} — the role ClickPipes uses to access your Aurora cluster.
Obtain the resource ID
- Log in to your AWS account and go to the Aurora cluster you want to configure.
- Select the Configuration tab.
- Note the Resource ID value — it looks like
cluster-xxxxxxxxxxxxxx. This is your{RDS_RESOURCE_ID}, which you reference in the permissions policy.
Create the IAM role
- Log in to your AWS account with an IAM user that has permission to create and manage IAM roles.
- Open the IAM console.
- Create a new IAM role with the following trust and permissions policies.
Trust policy (replace
{ClickHouse_IAM_ARN}with the IAM role ARN of your ClickHouse instance):{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "{ClickHouse_IAM_ARN}" }, "Action": [ "sts:AssumeRole", "sts:TagSession" ] } ] }Permissions policy (replace
{RDS_RESOURCE_ID}with the resource ID of your Aurora cluster,{RDS_REGION}with its region, and{AWS_ACCOUNT}with your AWS account ID):{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "rds-db:connect" ], "Resource": [ "arn:aws:rds-db:{RDS_REGION}:{AWS_ACCOUNT}:dbuser:{RDS_RESOURCE_ID}/clickpipes_iam_user" ] } ] } - Once the role is created, copy its ARN. This is your
{RDS_ACCESS_IAM_ROLE_ARN}.
You can now use this IAM role to authenticate with your Aurora cluster from ClickPipes.
配置网络访问
基于 IP 的访问控制
要限制发往 Aurora MySQL 实例的流量,请将文档中列出的静态 NAT IP 地址添加到 Aurora 安全组 (Security Group) 的入站规则中。


通过 AWS PrivateLink 进行私有访问
如需通过私有网络连接到您的 Aurora MySQL 实例,可使用 AWS PrivateLink。请按照 ClickPipes 的 AWS PrivateLink 设置指南 配置连接。
接下来做什么?
现在,您的Amazon Aurora MySQL 实例已配置好 binlog 复制,并已安全连接到 ClickHouse Cloud,您可以创建您的第一个 MySQL ClickPipe。如需了解 MySQL CDC (变更数据捕获) 的常见问题,请参阅 MySQL 常见问题页面。