From MySQL to MySQL

Supported Source and Destination Databases

Table 1 Supported databases

Service databases

DR Database

  • On-premises MySQL databases

  • MySQL databases on an ECS

  • MySQL databases on other clouds

  • RDS for MySQL

  • RDS for MySQL

Prerequisites

Suggestions

Caution

  • During the DR initialization, do not perform DDL operations on the service database. Otherwise, the task may be abnormal.

  • During DR initialization, ensure that no data is written to the DR database to ensure data consistency before and after DR.

  • The success of DR depends on environment and manual operations. To ensure a smooth DR, perform a DR trial before you start the DR task to help you detect and resolve problems in advance.

  • It is recommended that you start your DR task during off-peak hours to minimize the impact on your services.

    • If the bandwidth is not limited, initialization of DR will increase query workload of the source database by 50 MB/s and occupy 2 to 4 vCPUs.

    • To ensure data consistency, tables without a primary key may be locked for 3s during disaster recovery.

    • The data in the DR process may be locked by other transactions for a long period of time, resulting in read timeout.

    • If DRS concurrently reads data from a database, it will use about 6 to 10 sessions. The impact of the connections on services must be considered.

    • If you read a table, especially a large table, during DR, the exclusive lock on that table may be blocked.

  • Data-Level Comparison

    To obtain accurate comparison results, start data comparison at a specified time point during off-peak hours. If it is needed, select Start at a specified time for Comparison Time. Due to slight time difference and continuous operations on data, data inconsistency may occur, reducing the reliability and validity of the comparison results.

Precautions

Before creating a DR task, read the following precautions:

Table 2 Precautions

Type

Constraint

Database permissions

  • The service database user must have the following permissions:

    The user root of the RDS for MySQL instance has the following permissions by default: SELECT, CREATE, ALTER, DROP, DELETE, INSERT, UPDATE, TRIGGER, REFERENCES, SHOW VIEW, EVENT, INDEX, LOCK TABLES, CREATE VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, RELOAD, REPLICATION SLAVE, REPLICATION CLIENT, and WITH GRANT OPTION If the service database version is 8.0.14 to 8.0.18, the SESSION_VARIABLES_ADMIN permission is required.

  • The DR database user must have the following permissions:

    The user root of the RDS for MySQL instance has the following permissions by default: SELECT, CREATE, ALTER, DROP, DELETE, INSERT, UPDATE, TRIGGER, REFERENCES, SHOW VIEW, EVENT, INDEX, LOCK TABLES, CREATE VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, RELOAD, REPLICATION SLAVE, REPLICATION CLIENT, and WITH GRANT OPTION If the DR database version is 8.0.14 to 8.0.18, the SESSION_VARIABLES_ADMIN permission is required.

Disaster recovery objects

  • Tables with storage engine different to MyISAM and InnoDB do not support disaster recovery.

  • System tables are not supported.

  • Triggers and events do not support disaster recovery.

  • Accounts that have operation permissions on customized objects in the system database cannot be used for disaster recovery.

  • Backup and disaster recovery, cross-database DDL, and rename operations cannot be performed on some specified service databases. Otherwise, the disaster recovery fails.

Service database configuration

  • The binlog of the MySQL service database must be enabled and use the row-based format.

  • If the storage space is sufficient, store the service database binlog for as long as possible. The recommended retention period is seven days.

  • The service database username or password cannot be empty.

  • server_id in the MySQL service database must be set. If the service database version is MySQL 5.6 or earlier, the server_id value ranges from 2 to 4294967296. If the service database is MySQL 5.7 or later, the server_id value ranges from 1 to 4294967296.

  • GTID must be enabled for the database.

  • The service database name must contain 1 to 64 characters, including only lowercase letters, digits, hyphens (-), and underscores (_).

  • The table name and view name in the service database cannot contain non-ASCII characters, or the following characters: '<>/\

  • If the expire_logs_days value of the database is set to 0, the disaster recovery may fail.

DR database configuration

  • The DR DB instance is running properly. If the DR DB instance is a primary/standby instance, the replication status must also be normal.

  • The DR DB instance must have sufficient storage space.

  • The major version of the DR database must be the same as that of the service database.

  • The binlog of the DR database must be enabled and use the row-based format.

  • GTID must be enabled for the DR database.

  • Except the MySQL system database, the DR database must be empty. After a DR task starts, the DR database is set to read-only.

Precautions

  • Cascade operations cannot be performed on tables with foreign keys. If the foreign key index of a table is a common index, the table structure may fail to be created. You are advised to use a unique index.

  • The service database does not support point-in-time recovery (PITR).

  • Binlogs cannot be forcibly deleted. Otherwise, the DR task fails.

  • The service database does not support the reset master or reset master to command, which may cause DRS task failures or data inconsistency.

  • If the network is reconnected within 30 seconds, disaster recovery will not be affected. If the network is interrupted for more than 30 seconds, the DR task will fail.

  • Resumable upload is supported, but data may be repeatedly inserted into a table that does not have a primary key.

  • Migration or synchronization tasks cannot be created when a DR task exists.

  • The parameter modification of the service database is not recorded in logs and is not synchronized to the DR database. Therefore, you need to modify the parameters after the DR database is promoted to the primary.

  • If the service database and DR database are RDS MySQL instances, tables with TDE enabled cannot be created.

  • If a high-privilege user created in an external database is not supported by RDS MySQL, the user will not be synchronized to the DR database, for example, the super user.

  • If the external database does not provide the superuser permission, it cannot be set to read-only when it acts as a standby database. Ensure that the data of the standby node is synchronized only from the primary node. Any other write operations will pollute the data in the standby database, data conflicts may occur in the DR center and cannot be resolved.

  • If the external database is a standby and read-only database, only the account with the superuser permission can write data to that database. But you still need to ensure that data is written only by this account. Otherwise, the standby database may be polluted, and data conflicts occur in the DR center and cannot be resolved.

  • During disaster recovery, if the password of the service database is changed, the DR task will fail. To rectify the fault, you can correct the service database information on the DRS console and retry the task to continue disaster recovery. Generally, you are advised not to modify the preceding information during disaster recovery.

  • If the service database port is changed during disaster recovery, the DR task fails. Generally, you are advised not to modify the service database port during disaster recovery.

  • During disaster recovery, if the service database is on an RDS DB instance that does not belong the current cloud platform, the IP address cannot be changed. If the service database is an RDS instance on the current cloud and the DR task fails due to changes on the IP address, DRS automatically changes the IP address to the correct one. Then, you can retry the task to continue disaster recovery. Therefore, changing the IP address is not recommended.

  • During disaster recovery, you can create accounts for the service database.

  • During the DR initialization, do not perform DDL operations on the source database. Otherwise, the DR task may be abnormal.

  • Do not write data to the source database during the primary/standby switchover. Otherwise, data pollution or table structure inconsistency may occur, resulting in data inconsistency between the service database and DR database.

Procedure

  1. On the Disaster Recovery Management page, click Create Disaster Recovery Task.

  2. On the Create Disaster Recovery Instance page, specify the task name, description, and the DR instance details, and click Next.

    • Task information description

      Table 3 Task and recipient description

      Parameter

      Description

      Region

      The region where your service is running. You can change the region.

      Project

      The project corresponds to the current region and can be changed.

      Task Name

      The task name must start with a letter and consist of 4 to 50 characters. It can contain only letters, digits, hyphens (-), and underscores (_).

      Description

      The description consists of a maximum of 256 characters and cannot contain special characters !=<>'&"\

    • DR instance information

      Table 4 DR instance settings

      Parameter

      Description

      Disaster Recovery Relationship

      Select Current cloud as standby.

      By default, Current cloud as standby is selected. You can also select Current cloud as active.

      • Current cloud as standby: The DR database is on the current cloud.

      • Current cloud as active: The service database is on the current cloud.

      Service DB Engine

      Select MySQL.

      DR DB Engine

      Select MySQL.

      Network Type

      The public network is used as an example.

      Available options: VPN or Direct Connect and Public network. By default, the value is Public network.

      DR DB Instance

      The RDS instance you created.

      Disaster Recovery Instance Subnet

      Select the subnet where the disaster recovery instance is located. You can also click View Subnet to go to the network console to view the subnet where the instance resides.

      By default, the DRS instance and the destination DB instance are in the same subnet. You need to select the subnet where the DRS instance resides and ensure that there are available IP addresses. To ensure that the disaster recovery instance is successfully created, only subnets with DHCP enabled are displayed.

      Destination Database Access

      Select Read-only.

      During disaster recovery, the DR database becomes read-only. To change the DR database to Read/Write, you can change the DR database (or destination database) to a service database by clicking Promote Current Cloud on the Disaster Recovery Monitoring tab. After the DR task is complete or deleted, you can query and read data to the DR database.

      When the external database functions as the DR database, the user with the superuser permission can set the database to read-only.

      If a DRS instance node is rebuilt due to a fault, to ensure data consistency during the DRS task restoration, the current cloud standby database is set to read-only before the task is restored. After the task is restored, the synchronization relationship recovers.

    • Tags

      Table 5 Tags

      Parameter

      Description

      Tags

      • Tags a task. This configuration is optional. Adding tags helps you better identify and manage your tasks. Each task can have up to 20 tags.

      • After a task is created, you can view its tag details on the Tags tab. For details, see Tag Management.

    Note

    If a task fails to be created, DRS retains the task for three days by default. After three days, the task automatically ends.

  3. On the Configure Source and Destination Databases page, wait until the DR instance is created. Then, specify source and destination database information and click Test Connection for both the source and destination databases to check whether they have been connected to the DR instance. After the connection tests are successful, select the check box before the agreement and click Next.

    • Select Current cloud as standby for Disaster Recovery Relationship in 2.

      Table 6 Service database settings

      Parameter

      Description

      Source Database Type

      By default, Self-built on ECS is selected.

      IP Address or Domain Name

      The IP address or domain name of the service database.

      Port

      The port of the service database. Range: 1 - 65535

      Database Username

      The username for accessing the service database.

      Database Password

      The password for the service database username. You can change the password if necessary. To change the password, perform the following operation after the task is created:

      If the task is in the Starting, Initializing, Disaster recovery in progress, or Disaster recovery failed status, in the DR Information area on the Basic Information tab, click Modify Connection Details. In the displayed dialog box, change the password.

      Note

      The IP address, domain name, username, and password of the service database are encrypted and stored in DRS and will be cleared after the task is deleted.

      Table 7 DR database settings

      Parameter

      Description

      DB Instance Name

      The DB instance you selected when creating the DR task and cannot be changed.

      Database Username

      The username for accessing the DR database.

      Database Password

      The password for the database username. The password can be changed after a task is created.

      If the task is in the Starting, Initializing, Disaster recovery in progress, or Disaster recovery failed status, in the DR Information area on the Basic Information tab, click Modify Connection Details. In the displayed dialog box, change the password.

      The database username and password are encrypted and stored in DRS, and will be cleared after the task is deleted.

    • Select Current cloud as active for Disaster Recovery Relationship in 2.

      Table 8 Service database settings

      Parameter

      Description

      DB Instance Name

      The RDS instance selected when you created the DR task. This parameter cannot be changed.

      Database Username

      The username for accessing the service database.

      Database Password

      The password for the database username. You can change the password if necessary. To change the password, perform the following operation after the task is created:

      If the task is in the Starting, Initializing, Disaster recovery in progress, or Disaster recovery failed status, in the DR Information area on the Basic Information tab, click Modify Connection Details. In the displayed dialog box, change the password.

      The database username and password are encrypted and stored in the system and will be cleared after the task is deleted.

      Table 9 DR database settings

      Parameter

      Description

      Database Type

      By default, Self-built on ECS is selected.

      The destination database can be a Self-built on ECS or an RDS DB instance. If you select RDS DB instance, you need to select the region where the destination database is located. To use the RDS DB instance option, submit a service ticket.

      IP Address or Domain Name

      The IP address or domain name of the DR database.

      Port

      The port of the DR database. Range: 1 - 65535

      Database Username

      The username for accessing the DR database.

      Database Password

      The password for the DR database username. You can change the password if necessary. To change the password, perform the following operation after the task is created:

      If the task is in the Starting, Initializing, Disaster recovery in progress, or Disaster recovery failed status, in the DR Information area on the Basic Information tab, click Modify Connection Details. In the displayed dialog box, change the password.

      Region

      The region where the RDS DB instance is located. This parameter is available only when the source database is an RDS DB instance.

      DB Instance Name

      DR instance name. This parameter is available only when the source database is an RDS DB instance.

      Note

      When the DB instance is used as the DR database, it is set to read-only. After the task is complete, the DB instance can be readable and writable.

      Database Username

      Username for logging in to the DR database.

      Database Password

      Password for the database username.

      Note

      The IP address, domain name, username, and password of the DR database are encrypted and stored in DRS and will be cleared after the task is deleted.

  4. On the Configure DR page, specify flow control and click Next.

    Table 10 DR settings

    Parameter

    Description

    Flow Control

    You can choose whether to control the flow.

    • Yes

      You can customize the maximum DR speed.

      In addition, you can set the time range based on your service requirements. The traffic rate setting usually includes setting of a rate limiting time period and a traffic rate value. Flow can be controlled all day or during specific time ranges. The default value is All day. A maximum of three time ranges can be set, and they cannot overlap.

      The flow rate must be set based on the service scenario and cannot exceed 9,999 MB/s.

      **Figure 1** Flow control

      Figure 1 Flow control

    • No

      The DR speed is not limited and the outbound bandwidth of the source database is maximally used, which causes read consumption on the source database accordingly. For example, if the outbound bandwidth of the source database is 100 MB/s and 80% bandwidth is used, the I/O consumption on the source database is 80 MB/s.

      Note

      • Flow control mode takes effect during the initial DR phase only.

      • You can also change the flow control mode when the task is in the Configuration state. On the Basic Information tab, In the DR Information area, click Modify next to Flow Control. In the dialog box that is displayed, change the flow control mode. The flow control mode cannot be changed for a task that is in Starting state.

    Migrate Definer to User

  5. On the Check Task page, check the DR task.

    • If any check fails, review the failure cause and rectify the fault. After the fault is rectified, click Check Again.

    • If the check is complete and the check success rate is 100%, go to the Compare Parameter page.

      Note

      You can proceed to the next step only when all checks are successful. If there are any items that require confirmation, view and confirm the details first before proceeding to the next step.

  6. On the Confirm Task page, specify Start Time and DR instance details. Then, click Submit.

    Table 11 Task and recipient description

    Parameter

    Description

    Start Time

    Set Start Time to Start upon task creation or Start at a specified time based on site requirements.

    Note

    Starting a DR task may slightly affect the performance of the service and DR databases. You are advised to start a DR task during off-peak hours.

  7. After the DR task is submitted, view and manage it on the Disaster Recovery Management page.

    • You can view the task status. For more information about task status, see Task Statuses.

    • You can click image1 in the upper-right corner to view the latest task status.