Seamless Redis Migration: RDB/AOF, redis-dump, RedisShake & Docker Strategies
This guide outlines step‑by‑step methods for migrating a production Redis cluster—including using Redis’s native RDB/AOF backups, JSON‑based redis‑dump, the Alibaba‑maintained RedisShake tool, and Docker‑based cluster setups—ensuring data integrity and minimal downtime during the transition.
Problem
Due to various production environment constraints, we need to migrate the existing servers, including an online Redis cluster, while ensuring a smooth, seamless data transfer.
Solution Overview
Based on Redis's RDB/AOF backup mechanism
Execute save or bgsave to trigger data persistence and generate an RDB file.
Copy the Redis backup file (dump.rdb) to the target machine.
Restart the target instance and load the RDB file with load.
save vs bgsave : save is synchronous and blocks I/O; bgsave runs asynchronously, forks a child process and consumes additional memory.
Based on redis-dump JSON backup
redis-dump provides JSON‑based backup and restore for Redis data. Repository: https://github.com/delano/redis-dump
# Export command
redis-dump -u 127.0.0.1:6379 > lengleng.json
# Export specific database (e.g., DB 15)
redis-dump -u 127.0.0.1:6379 -d 15 > lengleng.json
# Export with password
redis-dump -u :[email protected]:6379 > lengleng.json
# Import command
redis-json -load
# Import with password
redis-json -load -u :[email protected]:6379Based on redis-shake for Redis cluster migration
Redis‑Shake is an open‑source tool from Alibaba Cloud for Redis data synchronization. Repository: https://github.com/alibaba/RedisShake
Docker‑based cluster setup
docker run --name redis-cluster1 -e CLUSTER_ANNOUNCE_IP=192.168.0.31 -p 8000-8005:7000-7005 -p 18000-18005:17000-17005 pig4cloud/redis-cluster:4.0
docker run --name redis-cluster2 -e CLUSTER_ANNOUNCE_IP=192.168.0.31 -p 8000-8005:7000-7005 -p 18000-18005:17000-17005 pig4cloud/redis-cluster:4.0Redis‑Shake configuration
source.type: cluster
source.address: [email protected]:7000 # auto‑discover node
target.type: cluster
target.address: [email protected]:8000 # auto‑discover nodeExecute full and incremental synchronization.
RESTful monitoring metrics
Users can view internal running status via a RESTful endpoint; the default port is 9320.
http://127.0.0.1:9320/metricSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
