This topic describes how to use the rump mode of redis-shake to migrate data from an ApsaraDB for Redis instance to another ApsaraDB for Redis instance under the same Alibaba Cloud account.

Prerequisites

  • An ApsaraDB for Redis instance is created as the destination of data migration.
  • The destination instance supports the data structure or modules of the source instance.
  • An Elastic Compute Service (ECS) instance is created for running the redis-shake tool.
  • The IP address of the ECS instance is added to the whitelists of both the source and destination ApsaraDB for Redis instances.
  • The ECS instance is running the Linux operating system.

Background

Redis-shake is an open-source tool developed by Alibaba Cloud. You can use it to parse (decode mode), recover (restore mode), back up (dump mode), and synchronize (sync/rump mode) Redis data. In rump mode, redis-shake can scan the source Redis to obtain full data and write the data to the destination Redis to migrate data. This migration solution does not use the SYNC or PSYNC command, and therefore has little impact on the service performance of Redis. It applies to Redis clusters and can be widely used to migrate data between on-premises Redis and ApsaraDB for Redis. This topic describes how to migrate data from an ApsaraDB for Redis instance to another ApsaraDB for Redis instance under the same Alibaba Cloud account.

For more information about the redis-shake tool, see redis-shake on GitHub or FAQ.

Warning The rump mode does not support incremental migration. We recommend that you stop writing data to the source Redis before migration to prevent data inconsistency.

Supported scenarios

  • Supports data migration between different cloud products. In this case, either the source or destination must support Internet access.
  • Supports data migration between versions. For example, you can migrate data from Redis 2.8 to Redis 4.0.
  • Supports data migration from hybrid-storage instances to Community Edition instances or performance-enhanced instances.

Procedure

  1. Log on to the ECS instance that can access both the source and destination ApsaraDB for Redis instances.
  2. Download redis-shake on the ECS instance.
    Note We recommend that you download the latest version of redis-shake.
  3. Run the following command to decompress the downloaded redis-shake.tar.gz package:
    # tar -xvf redis-shake.tar.gz
    Note In the decompressed folder, the redis-shake file is a binary file that can be run in the 64-bit Linux operating system. The redis-shake.conf file is the configuration file of the redis-shake tool. You need to modify this configuration file in the next step.
  4. Modify the redis-shake.conf file. The following table describes the parameters for the rump mode of the redis-shake tool.
    Table 1. Parameters for the rump mode of the redis-shake tool
    Parameter Description Example
    source.address The connection address and service port of the source ApsaraDB for Redis instance. r-bp1xxxxxxxxxxxxx.redis.rds.aliyuncs.com
    source.password_raw The password of the source ApsaraDB for Redis instance. SourcePass233
    Note If you use a database account other than the default database account to connect to the ApsaraDB for Redis instance, specify this parameter in the following format: account:password.
    target.address The connection address and service port of the destination ApsaraDB for Redis instance. r-j6cxxxxxxxxxxxxx.redis.rds.aliyuncs.com
    target.password_raw The password of the destination ApsaraDB for Redis instance. TargetPass233
    rewrite Specifies whether to overwrite the data on the ApsaraDB for Redis instance with the data in the RDB file if the data has the same key. Valid values:
    • true: overwrites the data with the same key.
    • false: does not overwrite the data with the same key.
    Note Default value: true. We recommend that you back up the valid data of the destination ApsaraDB for Redis instance before you perform data migration. If you set this parameter to false and a key exists in both the source and destination databases, an error message is returned.
    true
    scan.key_number The number of keys that redis-shake obtains each time it scans the source ApsaraDB for Redis instance. If you do not specify this parameter, the default value is set to 100. 100
    scan.special_cloud Specifies the specific edition of the source Redis instance. aliyun_cluster
    Note This value specifies that the data is migrated from a source ApsaraDB for Redis cluster instance.
  5. Run the following command to migrate data:
    # ./redis-shake -type=rump -conf=redis-shake.conf
    Note You must run this command in the same directory as the redis-shake and redis-shake.conf files. Otherwise, you need to specify the correct file path in the command.
    Figure 1. Migration example
    Note When the message circled in red in the preceding figure appears, the data is migrated. Then, you can use the redis-full-check tool to check whether the data in the source and destination databases are consistent. For more information, see Verify data after migration.