redis - 数据恢复

【基本介绍】
这里介绍redis数据恢复。

【基本方式】
redis有两种备份方式rdb和aof, 数据恢复只用把rdb活动aof文件放对应的redisdata目录下面就可以。
基本流程流程:
1.关闭redis,(因为关闭的时候会重写文件)
2.拷贝要恢复的数据到对应的redisdata目录
3.启动redis


rdb方式,关闭redis后要确认配置文件没有启用aof模式,否则启动的时候自动生成空aof文件,就无法导入数据。

aof方式,关闭redis后,拷贝aof文件到redisdata目录,重启后reids会自动读取aof文件。

所以针对rdb模式流程如下:
1.Stop redis (because redis overwrites the current rdb file when it exits).
2.Copy your backup rdb file to the redis working directory (this is the dir option in your redis config). Also make sure your backup filename matches the dbfilename config option.
3.Change the redis config appendonly flag to no (otherwise redis will ignore your rdb file when it starts).
4.Start redis.
5.Run redis-cli BGREWRITEAOF to create a new appendonly file.
6.Restore redis config appendonly flag to yes.


【参考引用】
[url]http://stackoverflow.com/questions/14497234/how-to-recover-redis-data-from-snapshotrdb-file-copied-from-another-machine[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值