Creating a Real-Time DR Task
To prevent service interruptions caused by regional faults, DRS provides disaster recovery to ensure service continuity. If the region where the primary instance is located encounters a natural disaster and cannot be connected, you can switch the remote DR instance to the primary instance. To reconnect to the primary instance, you only need to change the connection address on the application side. DRS allows you to perform cross-region real-time synchronization between a primary DB instance and a DR instance during disaster recovery.
This section uses two RDS for MySQL DB instances in different regions as an example to describe how to quickly create a remote single-active DR task through the public network.
Operation Process
Process |
Description |
---|---|
Sign up for a HUAWEI ID, complete real-name authentication, enable Huawei Cloud services, and prepare the database to be migrated, the database connection account, and a network. |
|
Select the source and destination databases as required and create a DR task. |
|
During the disaster recovery, check the DR progress. |
|
Compare objects and data to be synchronized to ensure data consistency. |
|
Perform a primary/standby switchover for the DR task. |
Preparations
Before creating a real-time DR task, prepare the Huawei account, database to be migrated, database connection account, and network environment by referring to the following steps.
Prepare a Huawei account, create a user, and grant permissions to the user to use DRS.
- Access Huawei Cloud website.
- Click Sign Up and follow the instructions to create your account (your HUAWEI ID).
- Select the service agreement and click Enable.
The system displays a message indicating that Huawei Cloud services have been enabled.
- Perform real-name authentication.
- Individual account: Individual Real-Name Authentication
- Enterprise account: Enterprise Real-Name Authentication
- For fine-grained permissions management, create an Identity and Access Management (IAM) user and user group on the IAM console and grant the user specific operation permissions. For details, see Creating a User and Granting Permissions
Before creating a real-time DR task, you need to prepare the source and destination databases.
- The source database in this example is an RDS for MySQL instance in the CN-Hong Kong region. For details, see Buy an RDS for MySQL DB Instance.
Item
Example Value
Description
Region
CN-Hong Kong
To reduce network latency, select the region nearest to you.
Instance name
rds-DRsrc
Specify a name that will be easy to identify.
DB engine version
MySQL 5.7
-
Instance type
Single
A single instance is used in this example.
To improve service reliability, select a primary/standby instance.
Storage type
Cloud SSD
-
AZ
AZ1
AZ1 is selected in this example.
To improve service reliability, select the primary/standby instance type and deploy the primary and standby instances in different AZs.
Instance class
General-purpose 2 vCPUs | 8 GB
-
EIP
10.154.217.42
Enter an IP address.
- The destination database in this example is an RDS for MySQL instance in the AP-Singapore region. For details, see Buy an RDS for MySQL DB Instance.
Item
Example Value
Description
Region
AP-Singapore
To reduce network latency, select the region nearest to you.
Instance name
rds-DRtar
Specify a name that will be easy to identify.
DB engine version
MySQL 5.7
-
Instance type
Single
A single instance is used in this example.
To improve service reliability, select a primary/standby instance.
Storage type
Cloud SSD
-
AZ
AZ1
AZ1 is selected in this example.
To improve service reliability, select the primary/standby instance type and deploy the primary and standby instances in different AZs.
Instance class
General-purpose 2 vCPUs | 8 GB
-
To ensure a smooth data disaster recovery, you are advised to create an independent database account for connecting to the DRS task. In addition, you need to ensure that the account is granted required permissions.
- Source database user
- Connect to an RDS for MySQL instance through DAS.
- Run the following statement to create database user usersrc. For details, see Creating a Database Account Through DAS.
CREATE USER 'usersrc'@'%' IDENTIFIED BY 'password';
- Run the following statements to grant permissions to usersrc:
GRANT 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 ON *.* TO 'usersrc'@'%' WITH GRANT OPTION;
- Destination database user
- Connect to an RDS for MySQL instance through DAS.
- Run the following statement to create database user usertar. For details, see Creating a Database Account Through DAS.
CREATE USER 'usertar'@'%' IDENTIFIED BY 'password';
- Run the following statement to grant permissions to usertar:
GRANT 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 ON *.* TO 'usertar'@'%' WITH GRANT OPTION;
Before creating a DR task over a public work, you need to apply for an EIP and set security group rules for the source database so that the EIP can access the source database.
- Create an EIP for the DR task by referring to Assigning an EIP.
- Configure security group rules for the source database.
Add the EIP in 1 of the DRS instance to the inbound rule of the security group associated with the source RDS for MySQL database, select TCP, and set the port number to that of the source database.
Step 1: Create a DR Task
This step describes how to set parameters based on the example values in Preparations. For more information about real-time disaster recovery, see DR Overview.
- Go to the Create Disaster Recovery Task page.
- Configure basic information as follows:
Figure 1 Basic information
Parameter
Example Value
Description
Billing Mode
Pay-per-use
DRS billing mode.
- Yearly/Monthly: A prepaid billing mode in which you pay for resources before using it. Bills are settled based on the subscription period.
- Pay-per-use billing: A postpaid billing mode. In this mode, you pay for what you used.
Region
AP-Singapore
The region where the current task is deployed.
Project
AP-Singapore
The project corresponds to the current region.
Task Name
DRS-DRTask
The name of the DR task.
Description
Leave this parameter blank for now.
Task description.
- Configure information about the disaster recovery instance.
Figure 2 Disaster recovery instance details
Parameter
Example Value
Description
Disaster Recovery Relationship
Current cloud as standby
The disaster recovery relationship of the DR task. The options are Current cloud as standby and Current cloud as active.
- Current cloud as standby: The DR database is a Huawei Cloud DB instance and data needs to be transferred to the cloud.
- Current cloud as active: The service database is a Huawei Cloud DB instance and data needs to be transferred out of the cloud.
Service DB Engine
MySQL
The DB engine type of the service database.
DR DB Engine
MySQL
The DB engine type of the DR database.
Network Type
Public network
The network type of the DR task.
DRS Task Type
Single-AZ
Type of the DRS task. The value can be Single-AZ or Dual-AZ.
DR DB Instance
rds-DRtar
Select a DR DB instance.
The DR DB instance is rds-DRtar in Databases.
Disaster Recovery Instance Subnet
Default subnet
The subnet where the DR task is.
Destination DB Instance Access
Read-only
During the disaster recovery, set the DR DB instance to the read-only state.
Enable Binlog Cleanup
No
Whether to enable the function of quickly clearing binlogs of the DR database.
Specify EIP
-
Select an EIP for the DRS instance. In this example, it is the EIP created in Network.
- Select the task specifications and AZ.
Figure 3 Specifications and AZ
Parameter
Example Value
Description
Specifications
Large
DRS instance specifications. Different specifications have different performance upper limits. For details, see Real-Time DR.
AZ
AZ1
Select the AZ where you want to create the DRS task.
- Configure an enterprise project and tags.
Figure 4 Enterprise Project and Tags
Parameter
Example Value
Description
Enterprise Project
default
If your account is associated with an enterprise project, select the project from the Enterprise Project drop-down list.
For more details, see Enterprise Management User Guide.
Tags
Leave this parameter blank for now.
Tags for the DR task. Adding tags helps you better identify and manage your tasks.
- Click Create Now.
Wait for 5 to 10 minutes. If the message "Disaster recovery instance created successfully" is displayed, the DRS task is successfully created.
- On the Configure Source and Destination Databases page, specify source and destination database details and click Test Connection for both the source and destination databases to confirm they have been connected to the DRS instance.
- In the Source Database area, enter the source database details in Connection Accounts.
- Click Test Connection.
If the message "Test successful" is displayed, the source database is connected.
- In the Destination Database area, enter the destination database details in Connection Accounts.
- Click Test Connection.
If the message "Test successful" is displayed, the destination database is connected.
- Click Next.
- On the Configure DR page, specify flow control and click Next.
- Set Flow Control to No.
- Set Migrate Definer to User to Yes.
Figure 5 DR settings
Parameter
Example Value
Description
Flow Control
No
Whether to set a maximum speed for the DR task. This function is disabled by default.
Migrate Definer to User
Yes
Whether to migrate the Definers of all source database objects to the destination database user entered during the connection test.
- On the Check Task page, check the DR task.
- If there are any items that require confirmation, view and confirm the details first before proceeding to the next step.
- If any of the checks fail, review the cause and rectify the fault. After the fault is rectified, click Check Again.
If the check success rate reaches 100%, the pre-check is successful.
- Click Next
- On the Compare Parameters page, compare and modify common and performance parameters.
- If you do not want to compare parameters or the parameters of the source database are the same as those of the destination database, skip this step.
- If the parameters of the source database are inconsistent with those of the destination database, you can manually change the values of the destination database parameters or click Use Source Database Value to make the parameter values of the source and destination database be the same.
- Click Next
- On the Confirm Task page, specify Start Time.
Figure 6 Task startup settings
Parameter
Example Value
Description
Start Time
Start upon task creation
Set Start Time to Start upon task creation or Start at a specified time based on site requirements. The Start at a specified time option is recommended.
Send Notifications
Disable
This parameter is optional. After enabled, select an SMN topic. If the status, latency metric, or data of the DR task is abnormal, DRS will send you a notification.
Stop Abnormal Tasks After
14
Any task in the Abnormal state that has run for longer than the period you set here (in days) will automatically stop.
- Confirm that the configured information is correct and click Submit to submit the task.
- After the DR task is submitted, go to the Disaster Recovery Management page to check the task status.
- If the task status is Starting, the task has been started.
- 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 for the task again.
Step 2: Query DR Progress
After the DR task is started, you can check the DR progress. DRS shows the DR progress using a progress bar, so you can track the DR progress in real time.
- On the Disaster Recovery Management page, click the target DR task in the Task Name/ID column.
The Basic Information page is displayed.
- Choose Disaster Recovery Progress to check the progress.
- When the data initialization is complete, the initialization progress is displayed as 100%.
- Delay refers to the delay from when the transaction was submitted to the source database to when it is synchronized to the destination database and executed.
When the delay is 0, data is synchronized from the service database to the DR database in real time. You can view more metrics, such as RPO and RTO, on the Disaster Recovery Monitoring tab.
- When the delay of the DR task is 0s, you can use data comparison to check whether the data in the service database is consistent with that in the DR database.
Step 3: Compare DR Items
When the task enters the Disaster recovery in progress state and the RPO and RTO are 0, you can create a comparison task to check whether the data in the source database is consistent with that in the destination database.
- Object-level comparison: It compares databases, indexes, tables, views, stored procedures and functions, and sorting rules of tables. You are advised to perform an object-level comparison first.
- Data-level comparison: It checks the consistency of rows or values in the migration tables.
You can create an object-level comparison task to check the integrity of database objects.
- On the Disaster Recovery Management page, click the target DR task in the Task Name/ID column.
The Basic Information page is displayed.
- Choose Disaster Recovery Comparison.
The Disaster Recovery Comparison page is displayed.
- Click Object-Level Comparison.
The Object-Level Comparison page is displayed.
- Click Compare.
- After 5 to 10 minutes, click to check the comparison result of each comparison item.
If Consistent is displayed in the Result column, the object migration is complete.Figure 7 Object-Level Comparison
After the database object comparison is complete, you can create a data-level comparison task to check the number of rows or values of the disaster recovery data.
- On the Disaster Recovery Management page, click the target DR task in the Task Name/ID column.
The Basic Information page is displayed.
- Choose Disaster Recovery Comparison.
The Disaster Recovery Comparison page is displayed.
- Click the Data-Level Comparison tab.
- Click Create Comparison Task.
- In the displayed dialog box, select a comparison policy and click OK.
Figure 8 Creating a comparison task
Parameter
Example Value
Description
Comparison Type
Row
The available options are Row and Value.
- Row comparison: It checks whether the number of rows in a service table is the same as that in the DR table.
- Value comparison: It checks whether the data in a service table is consistent with that in the DR table.
Comparison Time
Start upon task creation
The available options are Start upon task creation and Start at a specified time.
Filter Data
Disable
Whether to set filtering criteria for comparison objects. After this function is enabled, objects can be compared based on the configured filtering criteria.
Object
Select All
Select objects to be compared as needed.
- Go back to the Data-Level Comparison tab.
- Click to refresh the list. After the comparison task is complete, you can check the comparison result.
If Consistent is displayed in the Result column, the object data in the source database is consistent with that in the destination database.Figure 9 Row comparison result
Step 4 (Optional): Perform a DR Switchover
DRS allows you to perform a switchover for a DR task. When a disaster occurs, the DR database can be promoted to the service database to ensure service continuity.
- Before a switchover, services are running properly in the service database and data is synchronized to the DR database in real time. In this case, data cannot be written into the DR database.
- After a switchover, the DR database becomes readable and writable, services can be switched to the DR database, and data cannot be written to the service database.
- On the Disaster Recovery Management page, locate the target DR task.
- Click the task name.
The Basic Information page is displayed.
- Choose Disaster Recovery Progress to check the RPO and RTO.
- RPO measures the difference between the data in the service database and the data in the DRS instance. When RPO is 0, all the data in the service database has been migrated to the DRS instance.
- RTO measures the amount of data being transmitted. When RTO is 0, all transactions on the DRS instance have been completed on the DR database.
If both RPO and RTO are 0, data has been completely migrated to the DR database. Then, you can determine whether to perform a switchover.
- Choose Disaster Recovery Monitoring.
- A switchover can be performed only when the task status is Disaster recovery in progress.
- Click Promote Current Cloud to promote the current instance to the service database.
- Click Demote Current Cloud to demote the current instance to the DR database.
The DR relationship involves only one primary database. During a primary/secondary switchover, ensure that there is no data written to the database that will be the standby node, and no data will be written to the standby node in the future. 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 occur in the database and cannot be resolved.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot