Migrating Self-Built Redis Online
If the source self-host and target instances are interconnected and the SYNC and PSYNC commands are supported by the source instance, data can be migrated online in full or incrementally from the source to the target DCS.
During online migration, data is essentially synchronized in full to a new replica. Therefore, perform online migration during low-demand hours. Otherwise, source instance CPU usage may surge and latency may increase.
Notes and Constraints
- If the SYNC and PSYNC commands are disabled by the source instance, enable them before migrating data. Otherwise, the migration fails.
- You cannot use public networks for online migration.
- During online migration, you are advised to set repl-timeout on the source instance to 300s and client-output-buffer-limit to 20% of the maximum memory of the instance.
- The source must be Redis 3.0 or later.
Prerequisites
- Before migrating data, read through Migration Solution Notes to learn about the DCS data migration function and select an appropriate target instance.
- By default, a Proxy Cluster instance has only one database (DB0). Before you migrate data from a multi-DB single-node or master/standby instance to a Proxy Cluster instance, check whether any data exists on databases other than DB0. If yes, enable multi-DB for the Proxy Cluster instance by referring to Enabling Multi-DB.
- By default, a Redis Cluster instance has only one DB (DB0). Before you migrate data from a multi-DB single-node or master/standby instance to a Redis Cluster instance, check whether any data exists on databases other than DB0. To ensure that the migration succeeds, move all data to DB0 by referring to Online Migration from Another Cloud Using Rump.
- The IP address and port of the source Redis instance has been obtained.
- If a target DCS Redis instance is not available, create one first. For details, see Buying a DCS Redis Instance.
- If you already have a DCS Redis instance, you do not need to create one again. For comparing migration data and reserving sufficient memory, you are advised to clear the instance data before the migration. For details, see Clearing DCS Instance Data. If any data exists on the target instance, duplicate data between the source and target is overwritten. If the data exists only on the target instance, the data will be retained.
Creating an Online Migration Task
- Log in to the DCS console using the account of the target DCS Redis instance.
- Click in the upper left corner of the console and select the region where your target instance is located.
- In the navigation pane, choose Data Migration.
- Click Create Online Migration Task.
- Enter the task name and description.
The task name must start with a letter, contain 4 to 64 characters, and contain only letters, digits, hyphens (-), and underscores (_).
- Configure the VPC, subnet, and security group for the migration task.
- Select the same VPC as the target Redis. Ensure that the migration resource can access the target Redis instance.
- The online migration task uses a tenant IP address (Migration ECS displayed on the Basic Information page of the task.) If a whitelist is configured for the source or target instance, add the migration IP address to the whitelist or disable the whitelist.
- To allow the VM used by the migration task to access the source and target instances, set an outbound rule for the task's security group to allow traffic through the IP addresses and ports of the source and target instances. By default, all outbound traffic is allowed.
Checking the Network
- Check whether the source Redis instance, the target Redis instance, and the migration task are configured with the same VPC.
If yes, go to Creating an Online Migration Task. If no, go to 2.
- Check whether the VPCs configured for the source Redis instance, the target Redis instance, and the migration task are connected to ensure that the VM resource of the migration task can access the source and target Redis instances.
If yes, go to Configuring the Online Migration Task. If no, go to 3.
- Perform the following operations to establish the network.
- If the VPC of the source and target Redis instances are of the same cloud vendor and in the same region, create a VPC peering connection by referring to VPC Peering Connection.
- If the VPC of the source and target Redis instances are of the same cloud vendor but in different regions, create a cloud connection by referring to Cloud Connect Getting Started.
- If the source and target Redis instances are on different clouds, create a connection using only Direct Connect. For details, see Direct Connect documentation.
Configuring the Online Migration Task
- On the Online Migration tab page, click Configure in the row containing the online migration task you just created.
- Select a migration type.
Supported migration types are Full and Full + Incremental, which are described in Table 1.
Table 1 Migration type description Migration Type
Description
Full
Suitable for scenarios where services can be interrupted. Data is migrated at one time. Source instance data updated during the migration will not be migrated to the target instance.
Full + incremental
Suitable for scenarios requiring minimal service downtime. The incremental migration parses logs to ensure data consistency between the source and target instances.
Once the migration starts, it remains Migrating until you click Stop in the Operation column. After the migration is stopped, data in the source instance will not be lost, but data will not be written to the target instance. When the transmission network is stable, the delay of incremental migration is within seconds. The actual delay depends on the transmission quality of the network link.
Figure 1 Selecting the migration type
- Only if Migration Type is set to Full + Incremental, you can specify a bandwidth limit.
The data synchronization rate can be kept around the bandwidth limit.
- Specify Auto-Reconnect. If this option is enabled, automatic reconnections will be performed indefinitely in the case of a network exception.
Full synchronization will be triggered and requires more bandwidth if incremental synchronization becomes unavailable. Exercise caution when enabling this option.
- Configure Source Redis and Target Redis.
- Configure Source Redis Type and Source Redis Instance:
Set Redis in the cloud for Source Redis Type and add Source Redis Instance.
If the source Redis is a Redis Cluster, enter the IP addresses and ports of all masters in the cluster and separate multiple addresses with commas (,). For example: 192.168.1.1:6379,192.168.0.0:6379
- Configure Target Redis Type and Target Redis Instance:
Set Redis in the cloud for Target Redis Type and add Target Redis Instance.
- Configure Source Redis Instance Password and Target Redis Instance Password: If the instance is password-protected, click Test Connection to check whether the instance password is correct and whether the network is connected. If the instance is not password-protected, click Test Connection directly. If the test fails, check whether the password is correct, and whether the migration task network is connected.
- You can specify the source DB and target DB. For example, if you enter 5 for source DB and 6 for target DB, data in DB5 of the source Redis will be migrated to DB6 of the target Redis. If the source DB is not specified but the target DB is specified, all source data will be migrated to the specified target DB by default. If the target DB is not specified, data will be migrated to the corresponding target DB.
- If the source Redis is multi-DB and the target is single-DB (DB0), either ensure that all source data is in DB0, or specify a source DB and set the target DB to 0. Otherwise, migration will fail.
- For details about DB in DCS for Redis, see Does DCS for Redis Support Multi-DB?
- Configure Source Redis Type and Source Redis Instance:
- Click Next.
- Confirm the migration task details and click Submit.
Go back to the data migration task list. After the migration is successful, the task status changes to Successful.
If the migration fails, click the migration task and check the log on the Migration Logs page.
- Once incremental migration starts, it remains Migrating after full migration.
- To manually stop a migration task, select the check box on the left of the migration task and click Stop above the migration task.
- To perform migration again, select the migration tasks which failed or are stopped, and click Restart above. If a restarted migration task fails, click Configure to configure the task and try again.
- A maximum of 50 online migration tasks can be selected at a time. You can stop, delete, or restart them in batches.
Verifying the Migration
Before data migration, if the target Redis has no data, check data integrity after the migration is complete in the following way:
- Connect to the source Redis and the target Redis. Connect to Redis by referring to redis-cli.
- Run the info keyspace command to check the values of keys and expires.
- Calculate the differences between the values of keys and expires of the source Redis and the target Redis. If the differences are the same, the data is complete and the migration is successful.
During full migration, source Redis data updated during the migration will not be migrated to the target instance.
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