nav-img
Advanced

From GaussDB(for MySQL) to GaussDB(for MySQL) (Dual-Active DR)

Supported Source and Destination Databases

Table 1 Supported databases

Service database

DR Database

GaussDB(for MySQL) Primary/Standby

GaussDB(for MySQL) Primary/Standby

Database Account Permission Requirements

To start a DR task, the service and DR database users must meet the requirements in the following table. Different types of DR tasks require different permissions. For details, see Table 2. DRS automatically checks the database account permissions in the pre-check phase and provides handling suggestions.

Table 2 Database account permission

Type

Permission Required

Service database user

The user must have the following permissions:

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

The root account of the GaussDB(for MySQL) instance has the preceding permissions by default.

DR

database user

The user must have the following permissions:

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

The root account of the GaussDB(for MySQL) instance has the preceding permissions by default.

Note
  • You are advised to create an independent database account for DRS task connection to prevent task failures caused by database account password modification.
  • After changing the account passwords for the service and DR databases, modify the connection information of the DRS task by referring to Modifying Connection Information to prevent automatic retry after a task failure. Automatic retry will lock the database accounts.
  • Table 2 lists the minimum permissions required by a DRS task. If you need to migrate the grant permission through a DRS task, ensure that the connection account of the DRS task has the corresponding permission. Otherwise, the destination database user may not be authorized due to grant execution failure. For example, if the connection account of the DRS task does not require the process permission, but you need to migrate the process permission through a DRS task, ensure that the connection account of the DRS task has the process permission.

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 3 Precautions

Type

Restrictions

Disaster recovery objects

  • Only MyISAM and InnoDB tables 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.
  • DDL operations cannot be executed on the active database 2.
  • Disaster recovery for non-standard floating-point data that can be written in loose mode but cannot be written in strict mode is not supported. Such non-standard floating-point data may fail to be hit, causing data disaster recovery failures.

Service database configuration

  • The service database must be the primary node of the GaussDB(for MySQL) instance.
  • The binlog of the 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.
  • 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: '<>/\
  • The column names in the service database tables cannot end with a backslash (\).
  • 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 binlog of the DR database must be enabled and use the row-based format.
  • GTID must be enabled for the DR database.
  • The major version of the active database 1 must be the same as that of the active database 2.
  • Active database 2 must be an empty instance. After the forward task is started, active database 2 is set to read-only. After the backward task is started and DR is performed, active database 2 is restored to read/write.

Precautions

  • Dual-active DR supports backup in backward and forward directions. Due to certain uncontrollable factors, data may be inconsistent between the two sides. For example, if the load of active database 1 is too heavy and the load of active database 2 is light, data updates on the active database 1 synchronized to the active database 2 will be delayed due to the heave load, as a result, the operation sequence is changed and data becomes inconsistency. Therefore, divide data by unit (database, table, or row) and ensure the unit on one database is responsible for data read and write while on the other is read-only. In essence, in dual-active DR, both the databases play the active role but work differently. For details about common scenarios, see
  • Before creating a DRS task, if concurrency control rules of SQL statements are configured for the service or DR database, the DRS task may fail.
  • During the DR initialization, do not perform DDL operations on the source database. Otherwise, the DR task may be abnormal.
  • During disaster recovery, you can create accounts for the service database.
  • If the same data on both databases is updated simultaneously, data conflicts may occur. DRS resolves the conflict by overwriting the previous settings with the last settings.
    • When the deletion operation is performed, data is deleted and DRS does not perform any operation.
    • When the insert operation is performed, DRS updates data with the latest inserted data.
    • When the update operation is performed, the original data has been updated and DRS directly insert the new data.
  • Primary key conflicts between the two sides need to be avoided. For example, you can use a UUID or the primary key rule of region+auto-increment ID to avoid conflicts.
  • If the synchronization delay takes a long time due to connection interruption or network issues, you need to determine whether your services can tolerant the long-term delay.
  • 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.
  • If a physically generated column in a table is generated based on a time type, the data in the column may be inconsistent.
  • The dual-active DR is different from the single-active DR. Therefore, no active/standby switchover is required.
  • The DR latency is uncontrollable. Therefore, DDL operations must be performed when no service is running, and both RPO and RTO are zero and latency is kept within 30 seconds on active database 1. Do not perform DDL operations on active database 2. (DRS synchronizes only the DDL operations on active database 1 to active database 2.)
  • Ensure that the tables, columns, and rows are consistent in both the databases. (The table structures of both the active databases are consistent.)
  • A backward task can be started only when the forward task is in the DR process and both RPO and RTO are less than 60s.
  • After the dual-active DR task is in the DR process, perform tests on the active database 2 first. If the test results meet the requirements, switch certain service traffic to the active database 2.

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 Create Now.

    • Task information description
      Table 4 Task and recipient description

      Parameter

      Description

      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 5 DR instance settings

      Parameter

      Description

      Service DB Engine

      Select GaussDB(for MySQL).

      DR DB Engine

      Select GaussDB(for 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 GaussDB(for MySQL) instance you created.

      Disaster Recovery Instance Subnet

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

      By default, the DRS instance and the DR 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.

      Specify EIP

      This parameter is available when you select Public network for Network Type. Select an EIP to be bound to the DRS instance. DRS will automatically bind the specified EIP to the DRS instance and unbind the EIP after the task is complete. The number of specified EIPs must be the consistent with that of DB instances.

    • Specifications
      Table 6 Specifications

      Parameter

      Description

      AZ

      Select the AZ where you want to create the DRS task. Selecting the one housing the source or destination database can provide better performance.

    • Enterprise Project and Tags
      Table 7 Enterprise Project and Tags

      Parameter

      Description

      Enterprise Project

      An enterprise project you would like to use to centrally manage your cloud resources and members. Select an enterprise project from the drop-down list. The default project is default.

      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 stops.

  3. On the Disaster Recovery Management page, after the task is created, locate the forward subtask and click Edit in the Operation column. The Configure Source and Destination Databases page is displayed.
  4. 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.

    Table 8 Service database settings

    Parameter

    Description

    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 Connection 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 9 DR database settings

    Parameter

    Description

    DB Instance Name

    The GaussDB(for MySQL) instance you selected when creating the DR task. This parameter 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 Connection 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.

  5. 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 disaster recovery speed. During the disaster recovery, the speed of each task (or each subtask in multi-task mode) does not exceed the value of this parameter.

      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 Always. A maximum of 10 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.

    • 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 only in the DR initialization phase.
      • You can also change the flow control mode when the task is in the Configuration state. For details, see Modifying the Flow Control Mode.

    Migrate Definer to User

    Indicates whether to migrate the Definers of all source database objects to the destination database user entered during the connection test.

    • Yes
    • No

      The Definers of all source database objects will not be changed. You need to migrate all accounts and permissions of the source database in the next step. Note that if the Definer account is not found in the destination database, unavailable objects will be created.

  6. 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%, click Next.
      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.

  7. On the Confirm Task page, specify Start Time for the forward subtask. After confirming that the configured information is correct, click Submit to submit the forward DR task.

    Table 11 Task settings

    Parameter

    Description

    Start Time

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

    NOTE:

    After a DR task is started, the performance of the service and DR databases may be affected. You are advised to start a DR task during off-peak hours.

  8. Return to the Disaster Recovery Management page. After the forward subtask enters the Disaster recovery in progress state, locate the backward subtask and click Edit in the Operation column. The Configure Source and Destination Databases page of the backward subtask is displayed.

  9. On the Configure Source and Destination Databases page, click Test Connection for both the source and destination databases to check whether they have been connected to the disaster recovery instance. After the connection tests are successful, click Next.
  10. On the Confirm Task page, specify Start Time for the backward subtask. After confirming that the configured information is correct, click Submit to submit the backward DR task.
  11. After the 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 in the upper-right corner to view the latest task status.
    • By default, DRS retains a task in the Configuration state for three days. After three days, DRS automatically deletes background resources, but the task status remains unchanged. When you reconfigure the task, DRS applies for resources again.
    • For a public network task, DRS needs to delete background resources after you stop the task. The EIP bound to the task cannot be restored to the Unbound state until background resources are deleted.
    • For a task that is in the Disaster recovery in progress state, you can use data comparison to check whether data is consistent before and after the disaster recovery.