rdb (默认打开)触发条件
In the example below the behaviour will be to save:
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changed
save 900 1
save 300 10
save 60 10000
当写操作触发上面的条件,或者flashall, shutdown,都会马上持久化到rdb文件.
aof (默认关闭) 触发条件
appendonly no 改为yes开启
# appendfsync always
appendfsync everysec 每秒持久化
# appendfsync no
在生产环境一般rdb和aof同时存在,
如果rdb或者aof恢复数据的是很有问题,可以先进行检查.
redis-check-aof --fix 文件地址
然后启动redis服务