Enable the native replication feature

Updated at: 2025-02-13 02:00

This topic describes how to enable the native replication feature for an ApsaraDB RDS for MySQL instance. This topic also describes the permissions and limits of native replication in MySQL.

Important
  • The native replication feature is in invitational preview. To use the feature, submit a ticket to apply for a trial.

  • The native replication feature is available in the following zones and will be available in other zones in phases. If you require the feature, submit a ticket.

    • Hangzhou Zone J

    • Beijing Zone I and Beijing Zone K

    • Chengdu Zone A and Chengdu Zone B

    • Singapore Zone A

Permissions related to native replication

To improve user experience and ease of use, the privileged account of the RDS instance for which the native replication feature is enabled is granted additional permissions. In general, the permissions are not granted to the privileged account of RDS instances for which the feature is not enabled.

Native replication command permissions
Parameter modification permissions

The native replication feature allows the privileged account to execute the following MySQL native replication statements:

  • CHANGE MASTER TO: configures the replication between the primary database and the secondary database.

    For more information, see CHANGE MASTER TO.

  • START SLAVE;: starts a replication process.

    For more information, see START SLAVE.

  • STOP SLAVE;: stops a replication process.

    For more information, see STOP SLAVE.

  • RESET SLAVE;: resets the status of the secondary database and restarts the replication process from the primary database.

    For more information, see RESET SLAVE.

The native replication feature allows the privileged account to execute SQL statements to modify specific parameters:

  • Specify the read-only mode for the database server.

    SET GLOBAL read_only = ON/OFF;

    If you use the SET GLOBAL read_only = ON setting, the database server can process only read requests. If you use the SET GLOBAL read_only = OFF setting, the database server can process read and write requests.

  • Specify whether to record the SQL statements that are executed in the current session to binary logs.

    SET SESSION sql_log_bin = ON/OFF;

    If you use the SET SESSION sql_log_bin = ON setting, the SQL statements that are executed in the current session are recorded to binary logs. If you use the SET SESSION sql_log_bin = OFF setting, the SQL statements that are executed in the current session are not recorded to binary logs.

  • Specify the next global transaction identifier (GTID).

    SET SESSION GTID_NEXT = "your_gtid_value";

If an O&M operation, such as cross-host migration or specification change, is performed on your RDS instance, the native replication command permissions and parameter modification permissions are temporarily revoked. This does not affect the replication process. After the O&M operation is complete, the permissions become available again.

Limits

Limits on permissions
Limits on features
  • Limits on privileged accounts

    Specific super permissions of the native replication feature are granted to the privileged account of the RDS instance. Only the privileged account can execute native replication statements, such as CHANGE MASTER and START SLAVE.

  • Replication permission limits

    When you use the native replication feature to apply external binary logs, the native replication feature first checks the permissions. The binary logs that record operations not listed in the following section are not applied and the replication is interrupted.

    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, 
    DROP, RELOAD, PROCESS, REFERENCES, INDEX,
    ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,
    LOCK TABLES, EXECUTE, REPLICATION SLAVE,
    REPLICATION CLIENT, CREATE VIEW, SHOW VIEW,
    CREATE ROUTINE, ALTER ROUTINE, CREATE USER, 
    EVENT, TRIGGER ON *.* TO XXX; 
  • System database limits

    All operations on system databases are ignored. System databases include mysql, sys, information_schema, performance_schema, and __recyclebin__.

    Note

    Operations that indirectly modify databases, such as CREATE USER and GRANT, are not ignored. However, SQL statements must comply with the limits on replication permissions. Unauthorized operations, such as GRANT super on *.* to xxx;, interrupt the replication process.

  • GTID limits

    In MySQL native replication, the GTID modes of the primary and secondary databases must be the same. You cannot disable the GTID mode for an RDS instance. If your RDS instance serves as a secondary database and you want to establish a replication relationship between the RDS instance and an external primary database, you must enable the GTID mode for the external primary database to prevent compatibility issues.

    Before you establish the replication relationship, you must execute the SHOW VARIABLES LIKE 'gtid_mode'; statement on the external primary database to check whether the GTID mode is enabled. If the GTID mode is disabled, run the SET GLOBAL gtid_mode=ON; command to enable the GTID mode for the external primary database.

  • You cannot upgrade the major engine version of your RDS instance.

  • You cannot upgrade the RDS edition of your RDS instance from RDS Basic Edition to RDS High-availability Edition or RDS Cluster Edition.

  • You cannot switch your RDS instance to a different VPC.

  • You cannot use the restoration feature for individual databases and tables.

Enable the native replication feature

Prerequisites

Your RDS instance must meet the following requirements:

  • The RDS instance runs MySQL 5.7.

  • The RDS instance runs RDS Basic Edition.

  • The RDS instance uses the pay-as-you-go or subscription billing method.

  • The RDS instance runs a minor engine version of 20240930 or later.

  • The RDS instance resides in one of the following zones:

    • Hangzhou Zone J

    • Beijing Zone I and Beijing Zone K

    • Chengdu Zone A and Chengdu Zone B

    • Singapore Zone A

Note

You can go to the Basic Information page of your RDS instance to obtain the preceding information.

Procedure

  1. Optional. Create an RDS instance that runs RDS Basic Edition. For more information, see Create an ApsaraDB RDS for MySQL instance.

  2. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which your RDS instance resides. Then, find the RDS instance and click the instance ID.

  3. In the upper-right corner of the Basic Information page, click Enable Native Replication. image

  4. In the Enable Native Replication Mode dialog box, click OK.

  • On this page (1)
  • Permissions related to native replication
  • Limits
  • Enable the native replication feature
  • Prerequisites
  • Procedure
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare