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.


【参考引用】
http://stackoverflow.com/questions/14497234/how-to-recover-redis-data-from-snapshotrdb-file-copied-from-another-machine

猜你喜欢

转载自runpanda.iteye.com/blog/2155541
今日推荐