Redis持久化————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. 配置
redis.conf文件
#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持久化————AOF与RDB模式的更多相关文章
- Redis - 持久化 AOF 和 RDB
Redis - 持久化 AOF 和 RDB AOF AOF 持久化记录服务器执行的所有写操作命令,并在服务器启动时,通过重新执行这些命令来还原数据集. AOF 文件中的命令全部以 Redis 协议的格 ...
- Redis持久化 aof和rdb的原理配置
目录 一.介绍 二.RDB持久化(全量写入) rdb原理 rdb模式 rdb触发情况 rdb优势和劣势 rdb文件配置 rdb命令配置 rdb数据恢复 三.AOF持久化(增量写入) aof原理 aof ...
- redis持久化AOF与RDB
RDB 持久化可以在指定的时间间隔内生成数据集的时间点快照(point-in-time snapshot). AOF 持久化记录服务器执行的所有写操作命令,并在服务器启动时,通过重新执行这些命令来还原 ...
- redis 持久化 AOF和 RDB 引起的生产故障
概要 最近听开发的同事说,应用程序连接 redis 时总是抛出连接失败或超时之类的错误.通过观察在 redis 日志,发现日志中出现 "Asynchronous AOF fsyn ...
- Redis持久化AOF和RDB对比
RDB持久化 AOF持久化 全量备份,一次保存整个数据库 增量备份,一次保存一个修改数据库的命令 保存的间隔较长 保存的间隔默认一秒 数据还原速度快 数据还原速度一般 save会阻塞,但bgsave或 ...
- redis持久化AOF与RDB配置
AOF保存的数据方案时最完整的,如果同时开启了rdb和aof下,会采用aof方式. (1)设置数据保存到数据文件中的save规则 save 900 1 #900秒时间,至少有一条数据更新,则保 ...
- redis持久化的方式RDB 和 AOF
redis持久化的方式RDB 和 AOF 一.对Redis持久化的探讨与理解 目前Redis持久化的方式有两种: RDB 和 AOF 首先,我们应该明确持久化的数据有什么用,答案是用于重启后的数据恢复 ...
- Redis持久化——内存快照(RDB)
最新:Redis持久化--如何选择合适的持久化方式 最新:Redis持久化--AOF日志 最新:Redis持久化--内存快照(RDB) 一文回顾Redis五大对象(数据类型) Redis对象--有序集 ...
- Redis持久化——AOF日志
最新:Redis内存--内存消耗(内存都去哪了?) 最新:Redis持久化--如何选择合适的持久化方式 最新:Redis持久化--AOF日志 更多文章... 上一篇文章Redis持久化--内存快照(R ...
随机推荐
- xcode - 显示安装过的低版本模拟器
1. 更改版本
- OC 单例实现
2. 在.h 文件遵循 <NSCopying,NSMutabalecopying> 3.定义宏,实现任意类型单单例 #define SingleH(name) +(instancetype ...
- MacOs执行SQL出错(mysql)
上次修改过root密码之后,刚启动,执行sql就报错了. 错误是: Reset MySQL root password using ALTER USER statement after install ...
- Ubuntu下安装VirtualBox并为其添加USB支持
1.下载VirtualBox软件包和USB支持包 下载网址均为官方网站(可在此查看其使用教程):https://www.virtualbox.org/wiki/Downloads (若下载各平台各版本 ...
- Loadrunner脚本回放无法准确定位欲删除元素
Loadrunner脚本回放无法准确定位欲删除元素 问题: loadrunner脚本回放无法准确定位欲删除元素 详细: 我司ocrm系统,我的工作台菜单->我的综合工作台子页面下,工作日志页面删 ...
- Laravel Nginx 站点配置文件(Homestead)
server { listen 80; listen 443 ssl http2; server_name fmtmis.local; root "/home ...
- [Selenium]如何实现上传本地文件
public void uploadLocalFileToServer(String uploadFileName){ String AutomationPath = System.getProper ...
- hibernate4 , spring3 使用 org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean 报错 Implementing class
错误代码如下 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with ...
- attempt to create delete event with null entity
解决办法:删除之前判断是否为空 if(Object != null){ session.delete(Object); }
- [转]Go与C语言的互操作
Go有强烈的C背景,除了语法具有继承性外,其设计者以及其设计目标都与C语言有着千丝万缕的联系.在Go与C语言互操作(Interoperability)方面,Go更是提供了强大的支持.尤其是在Go中使用 ...