This topic describes how to create a reverse instance by using Data Transmission Service (DTS). This feature is used to synchronize data from a destination database back to the source database for database disaster recovery or workload switchover.
Prerequisites
A disaster recovery database is created. The available storage space of this database is larger than the total size of the data in the business database. We recommend that the available storage space of the disaster recovery database is 10% larger than the total size of the data in the business database.
Accounts are created for the business database and disaster recovery database to synchronize data. For information about the required permissions for the accounts, see Configure one-way data synchronization between ApsaraDB RDS for MySQL instances, Synchronize data between ApsaraDB RDS for SQL Server instances, Synchronize data from an ApsaraDB for MongoDB replica set instance to an ApsaraDB for MongoDB replica set or sharded cluster instance, and Synchronize data from an ApsaraDB for MongoDB sharded cluster instance to an ApsaraDB for MongoDB replica set or sharded cluster instance.
ImportantThe following permissions are granted to the disaster recovery database account:
If you synchronize data between SQL Server databases, the destination database account of the original data synchronization instance must have the permissions of the sysadmin role. You can grant the required permissions to the destination database account by using the system administrator account to run the following command:
EXEC sp_addsrvrolemember @loginame = N'<Account name>', @rolename = N'sysadmin';
.If you synchronize data between MySQL databases, the destination database account of the original synchronization instance must be granted the REPLICATION CLIENT, REPLICATION SLAVE, SHOW VIEW, and SELECT permissions. For more information, see GRANT Statement.
If you synchronize data between ApsaraDB for MongoDB instances, the destination database account of the original data synchronization instance must have the read permissions on the source database, the admin database, and the local database. For more information, see Use DMS to manage database accounts.
Usage notes
You can create a reverse instance only for a data synchronization instance between SQL Server databases, MySQL databases, or ApsaraDB for MongoDB instances. You can select only Incremental Data Synchronization for the Synchronization Types parameter when you configure the reverse instance.
The data that is directly written to the destination database of the original synchronization instance before a reverse instance is created is not synchronized.
A precheck is immediately performed after a reverse instance is created. After the precheck is passed, DTS collects the incremental data but does not write the data to the source database of the original synchronization instance.
You can create only one reverse instance for each synchronization instance. After the reverse instance is started, the original synchronization instance cannot be directly started.
You cannot create a reverse instance for a cross-border synchronization instance.
The tables to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, duplicate data records may occur.
You must set the retention period of binary logs based on the estimated time that is required for database restoration if an exception occurs in the business database.
If the original synchronization instance is a DTS Serverless instance, the reverse instance that you create for the original synchronization instance supports only the pay-as-you-go billing method and the micro instance class. If the original synchronization instance is a subscription or pay-as-you-go instance, the billing method and instance class of the reverse instance that you create for the original synchronization instance are the same as those of the original synchronization instance by default.
If the original synchronization instance is used for cross-region data synchronization, you must select the region in which the source database of the original synchronization instance resides before you can view the reverse instance that is created for the original synchronization instance on the Data Synchronization Tasks page.
You are still charged for a created reverse instance during the period when the reverse instance is paused.
If the business database fails to be connected due to exceptions, DTS instances enter the Retrying state.
Procedure
Database disaster recovery scenarios
Create a forward synchronization instance to synchronize data from the business database to the disaster recovery database based on your business requirements.
Select an instance class based on your business requirements and configure the Retry Time for Failed Connections parameter based on the estimated time that is required for database restoration if an exception occurs in the business database. For more information about how to create a forward synchronization instance, see Configure one-way data synchronization between ApsaraDB RDS for MySQL instances, Synchronize data between ApsaraDB RDS for SQL Server instances, Synchronize data from an ApsaraDB for MongoDB replica set instance to an ApsaraDB for MongoDB replica set or sharded cluster instance, and Synchronize data from an ApsaraDB for MongoDB sharded cluster instance to an ApsaraDB for MongoDB replica set or sharded cluster instance.
Wait until the forward synchronization instance enters the Running state and perform the following steps to create a reverse instance:
On the Data Synchronization Tasks page, find the synchronization instance that you have created.
Find the data synchronization instance that you want to manage, click the icon in the Actions column, and then select Create Reverse Task.
In the Note message, click OK.
Wait until the precheck of the reverse instance is complete and Performing Initial Synchronization is displayed in the Status column of the instance.
NoteIf Auto Refresh is disabled, you must click the icon above the Actions column to refresh the state of the reverse instance.Status
If the precheck fails, click View Cause. On the page that appears, click View Details in the Check Result column of the failed check item. Follow the instructions to resolve the issue and run the precheck again.
The reverse instance is created. No more operations are required if no exception occurs.
If the business database fails to be connected due to exceptions, perform the following steps to restore your business:
Pause the original instance.
On the Data Synchronization Tasks page, find the original instance.
In the Actions column, click the icon and select Pause Task.
In the Note dialog box, click OK.
In the The task is paused. message, click OK.
Switch your workloads to the disaster recovery database.
Start the reverse instance.
On the Data Synchronization Tasks page, click the ID of the reverse instance.
Optional. In the left-side navigation pane, click Task Management.
In the Progress section, click the Incremental Write module.
On the Basic Information tab, click Start Incremental Write next to Actions.
In the Note message, click OK.
After the business database is restored, perform the following steps to switch your workloads to the business database and restore the synchronization instances.
Switch your workloads to the business database.
Wait until the incremental synchronization task in the reverse direction is not delayed, pause the reverse instance.
The reverse instance synchronizes the data that is directly written to the disaster recovery database back to the business database.
Wait until the reverse instance is paused, start the forward synchronization instance.
Workload switchover scenarios
Create a reverse instance.
On the Data Synchronization Tasks page, find the forward synchronization instance, which is the original instance.
Find the data synchronization instance that you want to manage, click the icon in the Actions column, and then select Create Reverse Task.
In the Note message, click OK.
Wait until the precheck of the reverse instance is complete and Performing Initial Synchronization is displayed in the Status column of the instance.
NoteIf Auto Refresh is disabled, you must click the icon above the Actions column to refresh the state of the reverse instance.Status
If the precheck fails, click View Cause. On the page that appears, click View Details in the Check Result column of the failed check item. Follow the instructions to resolve the issue and run the precheck again.
The reverse instance is created. No more operations are required if no exception occurs.
Wait until the Incremental Data Collection module runs without latency.
Click the ID of the reverse instance. In the Progress section of the Task Management page, view the state and latency of the module.
Stop writing business data to the source database of the forward instance.
To avoid data loss, suspend your business and stop writing data to the database.
Pause the original instance.
On the Data Synchronization Tasks page, find the original instance.
In the Actions column, click the icon and select Pause Task.
In the Note dialog box, click OK.
In the The task is paused. message, click OK.
Switch your workloads to the destination database of the forward instance.
Start the reverse instance.
On the Data Synchronization Tasks page, click the ID of the reverse instance.
Optional. In the left-side navigation pane, click Task Management.
In the Progress section, click the Incremental Write module.
On the Basic Information tab, click Start Incremental Write next to Actions.
In the Note message, click OK.
Terminate or release the forward instance.
For more information, see Terminate a DTS instance and Release DTS instances.
FAQ
How do I select an instance class when I create a forward synchronization instance?
We recommend that you select the micro instance class that has the smallest maximum records per second (RPS). After you create a reverse instance, you can upgrade the instance based on your business requirements. For more information, see Upgrade a DTS instance.
What do I do if a DTS instance is in the Failed state after the business database is restored?
Start the DTS task. For more information, see Start a DTS task.