Step 4: Compare DR Items¶
Comparison Scenarios¶
DR item comparison: You can compare DR items to check data consistency between the service database and DR database. Currently, you can compare the following items during DR:
Object-level comparison: compares databases, events, indexes, tables, views, and triggers.
Data-level comparison is classified into row comparison and value comparison.
Row comparison: It helps you compare the number of rows in the tables to be synchronized. This comparison method is recommended because it is fast.
Value comparison: It helps you check whether data in the synchronized table is consistent. The comparison process is relatively slow.
To ensure that the comparison results are valid, compare data during off-peak hours by select Start at a specified time or compare cold data that is infrequently modified.
When you check data consistency, compare the number of rows first. If the number of rows are inconsistent, you can then compare the data in the table to determine the inconsistent data.
Constraints¶
If DDL operations were performed on the service database, you need to compare the objects again to ensure the accuracy of the comparison results.
If data in the DR database is modified separately, the comparison results may be inconsistent.
Currently, only tables with primary keys support value comparison. For tables that do not support value comparison, you can compare rows. Therefore, you can compare data by row or value based on scenarios.
To prevent resources from being occupied for a long time, DRS limits the row comparison duration. If the row comparison duration exceeds the threshold, the row comparison task stops automatically. If the service database is a relational database, the row comparison duration is limited within 60 minutes. If the service database is a non-relational database, the row comparison duration is limited within 30 minutes.
Impact on Databases¶
Object comparison: System tables of the source and destination databases are queried, occupying about 10 sessions. The database is not affected. However, if there are a large number of objects (for example, hundreds of thousands of tables), the database may be overloaded.
Row comparison: The number of rows in the source and destination databases is queried, which occupies about 10 sessions. The SELECT COUNT statement does not affect the database. However, if a table contains a large amount of data (hundreds of millions of records), the database will be overloaded and the query results will be returned slowly.
Value comparison: All data in the source and destination databases is queried, and each field is compared. The query pressure on the database leads to high I/O. The query speed is limited by the I/O and network bandwidth of the source and destination databases. Value comparison occupies one or two CPUs, and about 10 sessions.
Estimated Comparison Duration¶
Object comparison: Generally, the comparison results are returned within several minutes based on the query performance of the source database. If the amount of data is large, the comparison may take dozens of minutes.
Row comparison: The SELECT COUNT method is used. The query speed depends on the database performance.
Value comparison: If the database workload is not heavy and the network is normal, the comparison speed is about 5 MB/s.
Prerequisites¶
You have logged in to the DRS console.
A DR task has been started.
Procedure¶
On the Disaster Recovery Management page, click the target DR task in the Task Name/ID column.
On the Disaster Recovery Comparison tab, compare the service and DR databases.
Check the integrity of the database object.
Click Validate Objects. On the Object-Level Comparison tab, click Compare. Wait for a while and click , and view the comparison result of each comparison item.
Locate a comparison item you want to view and click View Details in the Operation column.
After the check is complete, compare the number of rows and values.
On the Data-Level Comparison tab, click Create Comparison Task. In the displayed dialog box, specify Comparison Type, Comparison Time, and Object. Then, click OK.
Comparison Type: compares rows and values.
Comparison Time: You can select Start upon task creation or Start at a specified time. There is a slight difference in time between the source and destination databases during synchronization. Data inconsistency may occur. You are advised to compare migration items during off-peak hours for more accurate results.
Object: You can select objects to be compared based on the scenarios.
Note
Data-level comparison cannot be performed for tasks in initialization.
After the comparison creation task is submitted, the Data-Level Comparison tab is displayed. Click to refresh the list and view the comparison result of the specified comparison type.
To view the comparison details, locate the target comparison type and click View Results in the Operation column. On the displayed page, locate a pair of service and DR databases, and click View Details in the Operation column to view detailed comparison results.
Note
You can also view comparison details of canceled comparison tasks.