将数据复制到 Azure Database for MySQLReplicate data into Azure Database for MySQL

备注

将要查看的是 Azure Database for MySQL 的新服务。You are viewing the new service of Azure Database for MySQL. 若要查看经典 MySQL Database for Azure 的文档,请访问此页To view the documentation for classic MySQL Database for Azure, please visit this page.

通过数据传入复制可以将数据从外部 MySQL 服务器同步到 Azure Database for MySQL 服务中。Data-in Replication allows you to synchronize data from an external MySQL server into the Azure Database for MySQL service. 外部服务器可以处于本地、虚拟机中或是其他云提供商托管的数据库服务。The external server can be on-premises, in virtual machines, or a database service hosted by other cloud providers. 复制中数据以基于二进制日志 (binlog) 文件位置的从本机到 MySQL 的复制为基础。Data-in Replication is based on the binary log (binlog) file position-based replication native to MySQL. 若要了解有关 binlog 复制的详细信息,请参阅 MySQL binlog 复制概述To learn more about binlog replication, see the MySQL binlog replication overview.

何时使用配置复制中数据When to use Data-in Replication

可以考虑使用复制中数据的主要场景有:The main scenarios to consider using Data-in Replication are:

  • 混合数据同步:借助复制中数据,可以在本地服务器和 Azure Database for MySQL 之间同步数据。Hybrid Data Synchronization: With Data-in Replication, you can keep data synchronized between your on-premises servers and Azure Database for MySQL. 此同步可用于创建混合应用程序。This synchronization is useful for creating hybrid applications. 如果有现有的本地数据库服务器,但想要将数据移到更靠近最终用户的区域,那么此方法很有吸引力。This method is appealing when you have an existing local database server but want to move the data to a region closer to end users.
  • 多云同步:对于复杂的云解决方案,使用复制中数据在 Azure Database for MySQL 和不同云提供程序之间同步数据,包括虚拟机和托管在这些云中的数据库服务。Multi-Cloud Synchronization: For complex cloud solutions, use Data-in Replication to synchronize data between Azure Database for MySQL and different cloud providers, including virtual machines and database services hosted in those clouds.

对于迁移方案,请使用 Azure 数据库迁移服务 (DMS)。For migration scenarios, use the Azure Database Migration Service(DMS).

限制和注意事项Limitations and considerations

不会复制的数据Data not replicated

不会复制主服务器上的 mysql 系统数据库The mysql system database on the master server isn't replicated. 不会复制对主服务器上的帐户和权限所做的更改。Changes to accounts and permissions on the master server aren't replicated. 如果在主服务器上创建帐户,并且此帐户需要访问副本服务器,则在副本服务器上手动创建相同的帐户。If you create an account on the master server and this account needs to access the replica server, manually create the same account on the replica server side. 若要了解哪些表包含在系统数据库中,请参阅 MySQL 手册To understand what tables are contained in the system database, see the MySQL manual.

FilteringFiltering

若要跳过从主服务器(托管在本地、在虚拟机中或在其他云提供程序托管的数据库服务中)复制表的操作,需支持 replicate_wild_ignore_table 参数。To skip replicating tables from your master server (hosted on-premises, in virtual machines, or a database service hosted by other cloud providers), the replicate_wild_ignore_table parameter is supported. (可选)使用 Azure 门户Azure CLI 在副本服务器(在 Azure 中托管)上更新此参数。Optionally, update this parameter on the replica server hosted in Azure using the Azure portal or Azure CLI.

查看 MySQL 文档详细了解此参数。Review the MySQL documentation to learn more about this parameter.

要求Requirements

  • 主服务器版本必须至少是 MySQL 5.6 版本。The master server version must be at least MySQL version 5.6.
  • 主服务器版本和副本服务器版本必须相同。The master and replica server versions must be the same. 例如,两者必须同时是 MySQL 5.6 版或 MySQL 5.7 版。For example, both must be MySQL version 5.6 or both must be MySQL version 5.7.
  • 每个表都必须有主键。Each table must have a primary key.
  • 主服务器应使用 MySQL InnoDB 引擎。Master server should use the MySQL InnoDB engine.
  • 用户必须具有权限才能在主服务器上配置二进制日志记录和创建新用户。User must have permissions to configure binary logging and create new users on the master server.
  • 如果主服务器启用了 SSL,请确保为域提供的 SSL CA 证书已包含在 mysql.az_replication_change_master 存储过程中。If the master server has SSL enabled, ensure the SSL CA certificate provided for the domain has been included in the mysql.az_replication_change_master stored procedure. 请参阅以下示例master_ssl_ca 参数。Refer to the following examples and the master_ssl_ca parameter.
  • 确保主服务器的 IP 地址已添加到 Azure Database for MySQL 副本服务器的防火墙规则中。Ensure the master server's IP address has been added to the Azure Database for MySQL replica server's firewall rules. 使用 Azure 门户Azure CLI 更新防火墙规则。Update firewall rules using the Azure portal or Azure CLI.
  • 确保托管主服务器的计算机在端口 3306 上允许入站和出站流量。Ensure the machine hosting the master server allows both inbound and outbound traffic on port 3306.
  • 请确保主服务器具有公共 IP 地址,DNS 可公开访问,或具有完全限定的域名 (FQDN)。Ensure the the master server has a public IP address, the DNS is publicly accessible, or has a fully qualified domain name (FQDN).

其他Other

  • 仅可在常规用途和优化内存定价层中使用数据传入复制功能。Data-in replication is only supported in General Purpose and Memory Optimized pricing tiers.
  • 不支持全局事务标识符 (GTID)。Global transaction identifiers (GTID) are not supported.

后续步骤Next steps