This topic describes how to migrate data from an AWS ElastiCache for Redis instance to an Alibaba Cloud ApsaraDB for Redis instance.

Prerequisites

  • An ApsaraDB for Redis instance is created as the destination of data migration. For more information, see Create an ApsaraDB for Redis instance.
  • An Elastic Compute Service (ECS) instance is created to run redis-shake. The 64-bit Linux operating system is running on the ECS instance. For more information, see Create an ECS instance.
  • The ECS instance can access the destination ApsaraDB for Redis instance.
    Note
    • If the ECS instance and the destination ApsaraDB for Redis instance are deployed in the same Virtual Private Cloud (VPC), you must add the internal IP address of the ECS instance to the whitelist of the destination ApsaraDB for Redis instance. For more information, see Set IP address whitelists.
    • If the ECS instance and the destination ApsaraDB for Redis instance are not deployed in the same VPC network, the ECS instance can access the destination ApsaraDB for Redis instance by using the public endpoint. For more information, see Through the Internet.

Precautions

  • We recommend that you stop writing data to the AWS ElastiCache for Redis instance before the migration.
  • We recommend that you back up your data before the migration.
  • We recommend that you schedule the service downtime before the migration.
  • If you migrate data on an AWS ElastiCache for Redis instance that is created on an Amazon Elastic Compute Cloud (Amazon EC2) instance, we recommend that you use Alibaba Cloud Data Transmission Service (DTS) to migrate data.

Back up and export data from AWS ElastiCache for Redis to an S3 bucket

  1. Create a backup for a specified cluster. Log on to the AWS ElastiCache console. In the left-side navigation pane, click Redis. Select the cluster that you want to back up, and click Backup. In the Create Backup dialog box that appears, select the Resource Name of the cluster, enter a Backup Name, and then click Create Backup.
  2. Export backup files to an AWS S3 bucket. Select Backups on the left of the dashboard. Select the backup file created in the preceding step, click Copy above the backup file list. In the Create a Copy of the Backup dialog box that appears, enter a New backup name, select a Target S3 location and click Copy on the lower right.
  3. You can find the exported RDB file in your S3 bucket.
  4. Download the RDB file from the S3 bucket.

Procedure

  1. Log on to the ECS instance that can access the destination ApsaraDB for Redis instance.
  2. Download the RDB file of the source AWS ElastiCache for Redis instance to an ECS instance.
    Note
    • You can run the wget <the download URL of the RDB file> command to download the RDS file to an ECS instance.
    • You can also use the MobaXterm Personal Edition client to upload the downloaded RDB file to an Alibaba Cloud ECS instance over SFTP.
  3. Download redis-shake on the ECS instance.
    Note We recommend that you download the latest version of redis-shake.
  4. 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 run in the 64-bit Linux operating system. The redis-shake.conf file is the configuration file of redis-shake. You must modify this configuration file.
  5. Modify the redis-shake.conf file. The following table describes the parameters for the restore mode of redis-shake.
    Table 1. Parameters for the restore mode of redis-shake
    Parameter Description Example
    rdb.input The path of the RDB file. You can specify either a relative path or an absolute path. /root/tools/RedisShake/demo.rdb
    target.address The connection address and port of the destination ApsaraDB for Redis instance. r-bp1xxxxxxxxxxxxx.redis.rds.aliyuncs.com:6379
    target.password_raw The password of the destination ApsaraDB for Redis instance. TargetPass233
    Note If you use a non-default database account to connect to the ApsaraDB for Redis instance, set this parameter in the format of account:password.
    target.db The database to which the data is recovered in the destination ApsaraDB for Redis instance. Default value: 0. For example, to recover the data of the source Amazon ElastiCache for Redis instance to db10 of the destination ApsaraDB for Redis instance, set this parameter to 10. If you set this parameter to a value less than 0, the data is recovered to db0. 0
    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
    parallel The number of concurrent threads used to synchronize the RDB file. You can increase the number of concurrent threads to improve the synchronization performance.
    Note
    • Minimum value: 1.
    • Maximum value: depends on the server performance.
    • Recommended value: 64.
    64
    Note You can use the default values for other parameters unless otherwise specified.
  6. Run the following command to recover data:
    # ./redis-shake -type=restore -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 must specify a valid file path in the command.
  7. When restore: rdb done appears in logs, the data is recovered. You can press Ctrl+C to exit the tool.
    Figure 1. Migration example