Skip to content

快速开始:从 dump.rdb 恢复数据

suxb201 edited this page Sep 26, 2022 · 2 revisions

这里举几个例子,演示使用 redis-shake 将 Redis 的备份文件(RDB文件)中的数据恢复至其他 Redis。

实例信息

dump.rdb 一份

绝对路径为:

/root/dump.rdb

单机实例 A

  • 地址:r-aaaaa.redis.zhangbei.rds.aliyuncs.com
  • 端口:6379
  • 密码:r-aaaaa:xxxxx

集群实例 B

  • 地址:
    • 192.168.0.1:6379
    • 192.168.0.2:6379
    • 192.168.0.3:6379
    • 192.168.0.4:6379
  • 密码:r-ccccc:xxxxx

dump.rdb 恢复至单机实例 A

  1. 修改 restore.toml 为:
type = "restore"

[source]
rdb_file_path = "/root/dump.rdb"

[target]
type = "standalone"
address = "127.0.0.1:6379"
password = "r-aaaaa:xxxxx"
  1. 运行 redis-shake:
redis-shake restore.toml

dump.rdb 恢复至集群实例 B

  1. 修改 restore.toml 为:
type = "restore"

[source]
rdb_file_path = "/root/dump.rdb"

[target]
type = "cluster"
address = "192.168.0.1:6379" # 这里写集群中的任意一个节点的地址即可
password = "r-ccccc:xxxxx"
  1. 运行 redis-shake:
redis-shake restore.toml