当前位置:网站首页>Redis AOF日志
Redis AOF日志
2022-07-01 22:58:00 【Mar丶流年】
为什么日志是后写入
因为日志没有语法检查,先写入日志,则可能写入错误命令。不利于redis使用日志恢复
后写入则是依靠redis执行,来保证命令的正确性
AOF三种落盘机制
写后落盘
redis执行完一条命令,写一次日志到磁盘中
写的操作阻塞线程,影响后续redis执行命令
效率:低
宕机 有可能丢失一条记录
一秒一写
redis执行完一条命令后,将命令写入AOF内存缓冲区
每隔一秒将缓冲区内容写入磁盘(异步)
效率:中
宕机 有可能丢失一秒内的日志
操作系统控制写回
redis执行完一条命令后,将命令写入AOF内存缓冲区
由操作系统控制何时写到磁盘中去(异步)
效率:高
宕机 有可能丢失大量日志
AOF重写
AOF重写的作用就是忽略过程,注重结果(反正我没事务)
假设我有个记录A,被100个命令修改了一百次,最后的结果是100
此时AOF记录就有100条,但是重写后就只有一条
即 A = 100
AOF重写减小日志大小
大文件是文件操作系统所不允许的
大文件的日志会影响写入速度
大文件的日志会影响redis的恢复速度
AOF重写机制
主线程fork出bgrewriteaof子进程
bgrewriteaof中拷贝redis内存数据
bgrewriteaof中的线程将reids内存数据 + AOF重写缓冲区数据 组成新的AOF 来替换旧的AOF
在AOF重写过程中,旧的AOF依旧在正常写入,来应对重写未完成时的宕机问题
AOF重写是会影响主线程的
1.在子进程拷贝数据时会阻塞主线程
2.在主线程操作已有数据时,也会阻塞
父子进程拷贝数据使用的是写时复制
子进程中只拷贝必要的数据结构
子进程和父进程指向相同的内存空间
当父进程进行写的操作时,才会分配新的内存地址,将数据拷贝进去
边栏推荐
- Matplotlib常用图表
- CKS CKA CKAD 将终端更改为远程桌面
- 物联网开发零基础教程
- 2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
- SWT / anr problem - SWT causes low memory killer (LMK)
- AAAI22 | 结构标记和交互建模:用于图分类的“SLIM”网络
- SWT / anr problem - SWT causes kernel fuse deadlock
- Jielizhi Bluetooth headset quality control and production skills [chapter]
- Oracle中已定义者身份执行函数AUTHID DEFINER与Postgresql行为的异同
- js——arguments的使用
猜你喜欢
为什么PHP叫超文本预处理器
Zero foundation tutorial of Internet of things development
2022 R1 fast opening pressure vessel operation test questions and answers
Istio、eBPF 和 RSocket Broker:深入研究服务网格
玻璃马赛克
Programming English vocabulary notebook
纪念成为首个DAYUs200三方demo贡献者
Experience of practical learning of Silicon Valley products
SWT/ANR问题--SWT 导致 kernel fuse deadlock
【小程序】通过scroll-view组件实现左右【滑动】列表
随机推荐
Redis数据类型和应用场景
2022 safety officer-c certificate examination question simulation examination question bank and simulation examination
Glass mosaic
上海炒股开户选择手机办理安全吗?
mysql binlog的清理
What is the mosaic tailgate?
Switch to software testing, knowing these four points is enough!
【无标题】
AirServer最新Win64位个人版投屏软件
Behind sharing e-commerce: the spirit of CO creation, symbiosis, sharing, CO prosperity and win-win
Future trend and development of neural network Internet of things
MySQL binlog cleanup
[micro service sentinel] sentinel integrates openfeign
CKS CKA CKAD 将终端更改为远程桌面
Airserver latest win64 bit personal screen projection software
物联网应用技术专业是属于什么类
flutter Unable to load asset: assets/images/888. png
from pip._ internal. cli. main import main ModuleNotFoundError: No module named ‘pip‘
dat. GUI
Compare the version number [double pointer to intercept the string you want]