AOF 和 RDB 模式
1.官方说明:
By default Redis asynchronously dumps the dataset on disk. This mode is
good enough in many applications, but an issue with the Redis process or
a power outage may result into a few minutes of writes lost (depending on
the configured save points).
The Append Only File is an alternative persistence mode that provides
much better durability. For instance using the default data fsync policy
(see later in the config file) Redis can lose just one second of writes in a
dramatic event like a server power outage, or a single write if something
wrong with the Redis process itself happens, but the operating system is
still running correctly.
AOF and RDB persistence can be enabled at the same time without problems.
If the AOF is enabled on startup Redis will load the AOF, that is the file
with the better durability guarantees.
Please check http://redis.io/topics/persistence for more information.
2.配置
#RDB模式配置
save 900 1 #当有一条Keys数据被改变时,15分钟刷新到Disk一次
save 300 10 #当有10条Keys数据被改变时,5分钟刷新到Disk一次
save 60 10000 #当有10000条Keys数据被改变时,1分钟刷新到Disk一次
#AOF模式配置
appendonly yes #启用AOF持久化方式
appendfilename appendonly.aof #AOF文件的名称,默认为appendonly.aof
# appendfsync always #每次收到写命令就立即强制写入磁盘,是最有保证的完全的持久化,但速度也是最慢的,一般不推荐使用。
appendfsync everysec #每秒钟强制写入磁盘一次,在性能和持久化方面做了很好的折中,是受推荐的方式。
# appendfsync no #完全依赖OS的写入,一般为30秒左右一次,性能最好但是持久化最没有保证,不被推荐。
no-appendfsync-on-rewrite yes #在日志重写时,不进行命令追加操作,而只是将其放在缓冲区里,避免与命令的追加造成DISK IO上的冲突。
auto-aof-rewrite-percentage 100 #当前AOF文件大小是上次日志重写得到AOF文件大小的二倍时,自动启动新的日志重写过程。
auto-aof-rewrite-min-size 64mb #当前AOF文件启动新的日志重写过程的最小值,避免刚刚启动Reids时由于文件尺寸较小导致频繁的重写。
3.比较测试:
在测试环境下,分别在RDB与AOF模式下,向redis-3.0.7写入同一数值。1秒后,使用killall -9 redis-server模拟生产事故发生。exists命令查看key, AOF模式恢复了kill之前写入的数值,而RDB模式没有恢复。
参考:http://redis.io/topics/persistence
分享到:
相关推荐
redis持久化,看完完全懂redis持久化,看完完全懂redis持久化,看完完全懂redis持久化,看完完全懂redis持久化,看完完全懂redis持久化,看完完全懂redis持久化,看完完全懂redis持久化,看完完全懂redis持久化,看...
02-Redis持久化、主从与哨兵架构详解.zip
解密Redis持久化
02-Redis持久化、主从与哨兵架构详解02-Redis持久化、主从与哨兵架构详解02-Redis持久化、主从与哨兵架构详解02-Redis持久化、主从与哨兵架构详解02-Redis持久化、主从与哨兵架构详解02-Redis持久化、主从与哨兵架构...
06_redis 持久化.pdf
主要介绍Redis持久化、主从与哨兵架构详解,详细具体,可操作性好!
介绍redis两种持久化方式及配置,以及它们各自的优缺点
Redis持久化、主从与哨兵架构详解(1)
很不错的redis持久化详细方案书籍,能帮助初学者快速的入门redis框架和运用。
Redis windows 测试redis持久化功能1
Redis持久化以及集群部署
Redis 有两种持久化方案,RDB (Redis DataBase)和 AOF (Append Only File)。如果你想快速了解和使用RDB和AOF,可以直接跳到文章底部看总结。本章节通过配置文件,触发快照的方式,恢复数据的操作,命令操作演示...
redis持久化 rar
Redis持久化 RDB快照(snapshot) 在默认情况下, Redis 将内存数据库快照保存在名字为 dump.rdb 的二进制文件中。 你可以对 Redis 进行设置, 让它在“ N 秒内数据集至少有 M 个改动”这一条件被满足时, 自动保存...
Redis持久化锦囊在手,再也不会担心数据丢失了(csdn)————程序
Redis持久化策略详解
基于北京尚硅谷周阳老师讲解的redis。个人学习总结: 包含redis常用命令,redis配置文件,redis持久化,redis事务,redis主从复制,jedis的使用。
Macbook Pro进行Docker安装Redis并配置Redis持久化
Redis持久化 - RDB和AOF