环境

  • Redis: 5.0.14

  • 源集群实例

    1
    2
    3
    
    ... 127.0.0.10:6371@16371 ... connected 0-5460
    ... 127.0.0.10:6372@16372 ... connected 5461-10922
    ... 127.0.0.10:6373@16373 ... connected 10923-16383
    
  • 源集群密码: 123456

  • 目的集群实例

    1
    2
    3
    
    ... 127.0.0.11:6371@16371 ... connected 0-5460
    ... 127.0.0.11:6372@16372 ... connected 5461-10922
    ... 127.0.0.11:6373@16373 ... connected 10923-16383
    
  • 目的集群密码: 123456

  • redis 数据迁移工具: redis-dump-go

导出源集群数据

  • 下载 redis-dump-go: https://github.com/yannh/redis-dump-go
  • 导出源集群中每个节点的数据
    1
    2
    3
    
    REDISDUMPGO_AUTH=123456 redis-dump-go -host 127.0.0.10 -port 6371 > redis-src-6371.resp
    REDISDUMPGO_AUTH=123456 redis-dump-go -host 127.0.0.10 -port 6372 > redis-src-6372.resp
    REDISDUMPGO_AUTH=123456 redis-dump-go -host 127.0.0.10 -port 6373 > redis-src-6373.resp
    

导入目的集群

  • 把数据导入与其 slots 一致的节点中
    1
    2
    3
    
    redis-cli -c -h 127.0.0.11 -p 6371 -a 123456 --no-auth-warning --pipe < redis-src-6371.resp
    redis-cli -c -h 127.0.0.11 -p 6372 -a 123456 --no-auth-warning --pipe < redis-src-6372.resp
    redis-cli -c -h 127.0.0.11 -p 6373 -a 123456 --no-auth-warning --pipe < redis-src-6373.resp