Hầu hết database migration tools hiện nay offline. Chúng phức tạp và yêu cầu manual intervention.
Nếu muốn migrate data từ Amazon ElastiCache sang Redis Enterprise Cloud, quy trình thường: backup ElastiCache data đến Amazon S3 bucket rồi import dùng Redis Enterprise Cloud UI. Process này có thể gây downtime đau đớn và data loss. Kỹ thuật khác: tạo point-in-time snapshots source Redis server và apply changes đến destination servers giữ cả hai in sync. Nghe hay nhưng challenging khi maintain chục script implement migration strategy.
Vì vậy chúng tôi đưa ra cách khác:
Giới thiệu RIOT
RIOT là open source online migration tool xây dựng bởi Julien Ruaux, Solution Architect tại Redis. RIOT implement client-side replication dùng producer/consumer approach. Producer là kết hợp key và value readers có kết nối ElastiCache. Key reader component xác định keys cần replicate dùng scan và keyspace notifications. Với mỗi key, value reader component thực hiện DUMP và handle key+bytes đến consumer (writer), thực hiện RESTORE trên Redis Enterprise connection.

Bài blog này show cách perform seamless online migration database từ ElastiCache sang Redis Enterprise Cloud.
Đừng bỏ lỡ: 6 Key Features Consider When Choosing a DBaaS Provider và How Redis Enterprise Cloud Meets the Needs of Maturing Enterprise Customers on AWS
Prerequisites:
Cần vài resource dùng migration tool:
- Redis Enterprise Cloud subscription
- Amazon ElastiCache (primary endpoint single-master EC, configuration endpoint clustered EC: xem Finding Connection Endpoints ElastiCache docs)
- Amazon EC2 instance based on Linux
Thiết lập Amazon EC2 instance
Tạo EC2 instance mới hoặc tận dụng existing. Ví dụ tạo instance trên AWS. Scenario phổ biến: access ElastiCache cluster từ EC2 instance cùng Amazon VPC. Dùng Ubuntu 16.04 LTS, nhưng chọn Ubuntu/Deb distribución tùy ý.
SSH kết nối EC2 instance mới từ máy tính:
ssh -i "public key" <AWS EC2 Instance>
Cài redis-cli tool instance mới chạy lệnh:
$ sudo apt update # sudo apt install -y redis-tools
Dùng redis-cli verify connectivity với ElastiCache database
Syntax:
$ redis-cli -h <Elasticache Primary Endpoint > -p 6379
Command:
$ sudo redis-cli -h <elasticache primary endpoint> -p 6379
Đảm bảo command cho phép connect remote Redis database thành công.
Sử dụng RIOT migration tool

Chạy command dưới setup migration tool.
Prerequisites:
Cài Java: Khuyến nghị OpenJDK 11 hoặc mới hơn:
sudo add-apt-repository ppa:openjdk-r/ppa && sudo apt-get update -q && sudo apt install -y openjdk-11-jdk
Cài đặt RIOT
Unzip package và đảm bảo RIOT binaries in place:
wget https://github.com/Redislabs-Solution-Architects/riot/releases/download/v2.0.8/riot-redis-2.0.8.zip unzip riot-redis-2.0.8.zip cd riot-redis-2.0.8/bin/
Check version RIOT:
./riot-redis --version RIOT version "2.0.8" bin/riot-redis --help Usage: riot-redis [OPTIONS] [COMMAND] -q, --quiet Log errors only -d, --debug Log in debug mode (includes normal stacktrace) -i, --info Set log level to info -h, --help Show this help message and exit. -V, --version Print version information and exit. Redis connection options -r, --redis=<uri> Redis connection string (default: redis://localhost:6379) -c, --cluster Connect to a Redis Cluster -m, --metrics Show metrics -p, --pool=<int> Max pool connections (default: 8) Commands: replicate, r Replicate a source Redis database in a target Redis database info, i Display INFO command output latency, l Calculate latency stats ping, p Execute PING command
Sau khi Java và RIOT cài xong, ready begin migration process với command dưới, replicate trực tiếp từ source (ElastiCache) đến target (Redis Enterprise Cloud).
Cuối cùng, replicate data ElastiCache sang Redis Enterprise Cloud chạy command:
sudo ./riot-redis -r redis://<source Elasticache endpoint>:6379 replicate -r redis://password@<Redis Enterprise Cloud endpoint>:port --live
ElastiCache cho phép cấu hình 2 cách: clustered và non-clustered. Bảng dưới, hàng đầu command cho non-clustered, hàng 2 cho clustered với specific database namespace:

Nhìn thấy, khi clustered ElastiCache, cần pass –cluster option trước source ElastiCache endpoint.
Lưu ý quan trọng
- Thực hiện user acceptance testing migration trước production.
- Sau migration complete, đảm bảo application traffic redirect thành công đến Redis Enterprise endpoint.
- Thực hiện migration lúc low traffic minimize data loss chance.
Kết luận
Nếu tìm simple, easy-to-use live migration tool move data từ Amazon ElastiCache sang Redis Enterprise Cloud no downtime, RIOT là lựa chọn promising.
References:
- RIOT – Redis input/output tools