Redis backup and recovery

  • Backup
    dump.rdb: RDB way of backup files
    backup files AOF way: appendonly.aof
rdb 备份处理
# 编辑redis.conf文件,找到如下参数,默认开启。
save 900 1
save 300 10
save 60 10000

aop备份处理
# 编辑redis.conf文件,找到如下参数,默认关闭。
appendonly yes          #开启持久化
appendfsync everysec    #每秒备份一次

命令:
bgsave              #异步保存数据到磁盘(快照保存)
lastsave            #返回上次成功保存到磁盘的unix的时间戳
shutdown            #同步保存到服务器并关闭redis服务器
bgrewriteaof        #文件压缩处理(命令)
  • restore

If you need to restore data, redis stopped the backup file (dump.rdb) or (appendonly.aof) move to redis installation directory and start the service.

Get redis directory CONFIG command may be used, as follows:

127.0.0.1:6379> CONFIG GET dir
1) "dir"
2) "/usr/local/redis"
#/usr/local/redis即为redis安装目录

Guess you like

Origin www.cnblogs.com/Smbands/p/11459816.html