全库迁移

登录主库
redis-cli
save #保存数据到硬盘

复制到dump.rdb文件到目录服务器
#重新

工具下载

https://github.com/alibaba/RedisShake

  • docker-compose.yml
version: '3.8'
services:
  redis-shake:
    image: golang:1.18
    restart: always
    #network_mode: host
    container_name: redis-shake
    volumes: 
      - "./data:/home"
      - "./RedisShake:/RedisShake"
    working_dir: /RedisShake
    tty: true
    privileged: true

启动容器编译

docker exec -it redis-shake bash
go env -w GOPROXY=https://goproxy.io,direct
sh build.sh

实例

同步数据

cd bin
./redis-shake xx.yaml 

#vi xx.yaml 
type = "sync"
[source]
address = "192.168.1.10:6379"
password = "xxxx"

[target]
type = "standalone"
address = "192.168.1.100:6379"
password = "xxxx"

恢复数据

redis-shake restore.toml

#vi restore.toml
type = "restore"
[source]
rdb_file_path = "/root/dump.rdb"

[target]
type = "standalone"
address = "127.0.0.1:6379"
password = "r-aaaaa:xxxxx"