You can use redis-port to migrate data from a self-managed Redis database to an ApsaraDB for Redis instance.

Prerequisites

  • You have created a Linux-based Elastic Compute Service (ECS) instance in the VPC where the target ApsaraDB for Redis instance resides.
  • You have downloaded redis-port in the ECS instance mentioned above.
  • You have run chmod u+x redis-port to change redis-port into an executable file.

Procedure

  1. Log in to the Linux system built in your ECS instance.
  2. In the directory where redis-port resides, run below code to start the migration.
    ./redis-port sync --from=src_host:src_port --Password=src_password --target=dst_host:dst_port --auth=dst_password [--filterkey="str1|str2|str3"] [--targetdb=dB] [--rewrite] [--bigkeysize=size] [--logfile=redisport.log]
    Table 1. Redis-port Arguments
    Argument Description
    src_host Domain name (or IP) of the self-managed Redis database.
    src_port Port of the self-managed Redis database.
    src_password Password of the self-managed Redis database.
    dst_host Domain name of the ApsaraDB for Redis instance.
    dst_port Port of the ApsaraDB for Redis instance.
    dst_password Password of the ApsaraDB for Redis instance.
    str1|str2|str3 Filter keys with str1, str2, or str3.
    DB Index of the self-managed Redis DB to be migrated.
    rewrite Overwrite identical keys that already exist in the ApsaraDB for Redis instance.
    Notice If this argument is not set and identical keys exist in both databases, the migration may not run properly.
    bigkeysize While writing keys larger than the value of size, enable big-key writing.
    logfile Specify a file to save the logs.
  3. Monitor the logs to make sure the migration procedure runs as expected.

    Note
    • Check the logs after sync rdb done, if the +nbytes value of an entry containing +forward=1 is greater than 14, it is an incremental-synchronization log. You can monitor the status of the incremental synchronization to determine the best time to switch databases.
    • After full synchronization, the synchronization source (i.e. the self-managed Redis database) will send periodic ping requests, generating logs with +forward=1 and +nbytes=14. These are not incremental-synchronization logs.