Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Online Migration from Another Cloud Using redis-shake

Updated on 2024-07-29 GMT+08:00

redis-shake is an open-source Redis migration tool. Its rump mode allows you to obtain the full data of a source Redis using the SCAN command and write the data to a target Redis. This migration solution does not involve the SYNC or PSYNC command and can be widely used for migration between self-built Redis and cloud Redis.

This section describes how to use the rump mode of redis-shake to migrate the full Redis data of another cloud service vendor at a time online to DCS.

Figure 1 Data flow in this solution

Prerequisites

  • A DCS Redis instance has been created on the target cloud.
  • An ECS has been created on the target cloud for running redis-shake.
  • The ECS is in the same VPC as the DCS Redis instance and bound with an EIP.
  • The rump mode does not support incremental data migration. To keep data consistency, stop writing data to the source Redis before migration.
  • This solution applies only to same-database mapping and does not apply to inter-database mapping.
  • If the source Redis has multiple databases (there are databases other than DB0), and your DCS instance is a cluster, this solution cannot be used. (Cluster DCS instances support only DB0.)

Procedure

  1. Install Nginx on the ECS and the source forwarding server. The following describes how to install Nginx on an ECS running CentOS 7.x. The commands vary depending on the OS.

    1. Add Nginx to the Yum repository.
      sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    2. Check whether Nginx has been added successfully.
      yum search nginx
    3. Install Nginx.
      sudo yum install -y nginx
    4. Install the stream module.
      yum install nginx-mod-stream --skip-broken
    5. Start Nginx and set it to run automatically upon system startup.
      sudo systemctl start nginx.service
      sudo systemctl enable nginx.service
    6. In the address box of a browser, enter the server address (the EIP of the ECS) to check whether Nginx is installed successfully.

      If the following page is displayed, Nginx has been installed successfully.

  2. Add the source forwarding server to the whitelist of the source Redis.
  3. Configure a security group for the source forwarding server.

    1. Obtain the EIP of the ECS.
    2. In the inbound rule of the security group of the source forwarding server, add the EIP of the ECS, and open the port that ECS's requests come through. The following takes port 6379 as an example.

  4. Configure Nginx forwarding for the source forwarding server.

    1. Log in to the Linux source forwarding server and run the following commands to open and modify the configuration file:
      cd /etc/nginx
      vi nginx.conf
    2. Example forwarding configuration:
      stream {
          server {
              listen 6379;
              proxy_pass {source_instance_address}:{port};
          }
         }

      6379 is the listening port of the source forwarding server. {source_instance_address} and {port} are the connection address and port of the source Redis instance.

      This configuration allows you to access the source Redis through the local listening port 6379 of the source forwarding server.

      This configuration must be added exactly where it is shown in the following figure.

      Figure 2 Configuration location
    3. Restart Nginx.
      service nginx restart
    4. Verify whether Nginx has been started.
      netstat -an|grep 6379

      If the port is being listened, Nginx has been started successfully.

      Figure 3 Verification result

  5. Configure Nginx forwarding for the ECS.

    1. Log in to the Linux ECS and run the following commands to open and modify the configuration file:

      cd /etc/nginx

      vi nginx.conf

    2. Configuration example:
      stream {
          server {
              listen 6666;
              proxy_pass {source_ecs_address}:6379;
          }
         }

      6666 is ECS's listening port, {source_ecs_address} is the public IP address of the source forwarding server, and 6379 is the listening port of the source forwarding server Nginx.

      This configuration allows you to access the source forwarding server through the local listening port 6666 of the ECS.

      This configuration must be added exactly where it is shown in the following figure.

      Figure 4 Configuration location
    3. Restart Nginx.
      service nginx restart
    4. Verify whether Nginx has been started.
      netstat -an|grep 6666

      If the port is being listened, Nginx has been started successfully.

      Figure 5 Verification result

  6. Run the following command on the ECS to test the network connection of port 6666:

    redis-cli -h {target_ecs_address} -p 6666 -a {password}

    {target_ecs_address} is the EIP of the ECS, 6666 is the listening port of the ECS, and {password} is the source Redis password. If there is no password, leave it blank.

    Figure 6 Connection example

  7. Prepare the migration tool redis-shake.

    1. Log in to the ECS.
    2. Download redis-shake. Version 2.0.3 is used as an example. You can use other redis-shake versions as required.
      wget https://github.com/tair-opensource/RedisShake/releases/download/release-v2.0.3-20200724/redis-shake-v2.0.3.tar.gz
    3. Decompress the redis-shake file.
      tar -xvf redis-shake-v2.0.3.tar.gz

  8. Configure the redis-shake configuration file.

    1. Go to the directory generated after the decompression.
      cd redis-shake-v2.0.3
    2. Modify the redis-shake.conf configuration file.
      vim redis-shake.conf

      Modify the source Redis configuration.

      • source.type

        Type of the source Redis instance. Use standalone for single-node, master/standby, and Proxy Cluster, and cluster for cluster instances.

      • source.address

        EIP of the ECS and the mapped port of the source forwarding server (ECS's listening port 6666). Separate the EIP and port number with a colon (:).

      • source.password_raw

        Password of the source Redis instance. If no password is set, you do not need to set this parameter.

      Modify the target DCS configuration.

      • target.type

        Type of the DCS Redis instance. Use standalone for single-node, master/standby, and Proxy Cluster, and cluster for cluster instances.

      • target.address

        Colon (:) separated connection address and port of the DCS Redis instance.

      • target.password_raw

        Password of the DCS Redis instance. If no password is set, you do not need to set this parameter.

    3. Press Esc to exit the editing mode and enter :wq!. Press Enter to save the configuration and exit the editing interface.

  9. Run the following command to start redis-shake and migrate data in the rump (online in full) mode:

    ./redis-shake.linux -conf redis-shake.conf -type rump
    Figure 7 Migration process
    Figure 8 Migration result

  10. After the migration is complete, use redis-cli to connect to the source and target Redis instances to check whether the data is complete.

    1. Connect to the source and target Redis instances, respectively.

      For details, see Accessing a DCS Redis Instance Through redis-cli.

    2. Run the info keyspace command to check the values of keys and expires.
    3. 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.

  11. Delete the redis-shake configuration file.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback