当前位置:网站首页>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.在主线程操作已有数据时,也会阻塞
父子进程拷贝数据使用的是写时复制
子进程中只拷贝必要的数据结构
子进程和父进程指向相同的内存空间
当父进程进行写的操作时,才会分配新的内存地址,将数据拷贝进去
边栏推荐
- CKS CKA CKAD 将终端更改为远程桌面
- SWT / anr problem - SWT causes low memory killer (LMK)
- Y53. Chapter III kubernetes from introduction to mastery -- ingress (26)
- What is the relationship between modeling and later film and television?
- flutter Unable to load asset: assets/images/888. png
- Jielizhi Bluetooth headset quality control and production skills [chapter]
- Current situation and future development trend of Internet of things
- Use 3DMAX to make a chess piece
- 玻璃马赛克
- The digital summit is popular, and city chain technology has triggered a new round of business transformation
猜你喜欢

Use 3DMAX to make a chess piece

CKS CKA ckad change terminal to remote desktop

Experience of practical learning of Silicon Valley products

CKS CKA CKAD 将终端更改为远程桌面

物联网开发零基础教程

2022 safety officer-c certificate examination question simulation examination question bank and simulation examination

Matplotlib常用设置
![[applet] realize the left and right [sliding] list through the scroll view component](/img/18/b1b4e9923782856143721dad84cbab.png)
[applet] realize the left and right [sliding] list through the scroll view component

Stm32f030f4 drives tim1637 nixie tube chip

Wechat personal small store one click opening assistant applet development
随机推荐
Matplotlib常用設置
【微服务|Sentinel】sentinel整合openfeign
2021 RoboCom 世界机器人开发者大赛-高职组复赛
mysql ---- Oracle中的rownum转换成MySQL
YOGA27多维一体电脑,兼具出色外观与高端配置
2022年危险化学品经营单位安全管理人员考试题及在线模拟考试
Future trend and development of neural network Internet of things
2022 R1 fast opening pressure vessel operation test questions and answers
Current situation and future development trend of Internet of things
Postgresql随手记(10)动态执行EXECUTING语法解析过程
Daily three questions 6.30
Istio、eBPF 和 RSocket Broker:深入研究服务网格
[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing
Redis~02 cache: how to ensure data consistency in MySQL and redis when updating data?
typescript枚举
CADD课程学习(3)-- 靶点药物相互作用
js——arguments的使用
Daily three questions 6.29
Know --matplotlib
Development trend and future direction of neural network Internet of things