当前位置:网站首页>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.在主线程操作已有数据时,也会阻塞
父子进程拷贝数据使用的是写时复制
子进程中只拷贝必要的数据结构
子进程和父进程指向相同的内存空间
当父进程进行写的操作时,才会分配新的内存地址,将数据拷贝进去
边栏推荐
- 转行软件测试,知道这四点就够了!
- mt管理器测试滑雪大冒险
- "35 years old, the boss of the company, with a monthly salary of 20000, give away takeout": the times abandoned you, not even saying goodbye
- 数字峰会人气火爆,城链科技引发新一轮商业变革
- plain framework的实际应用和扩展
- 为什么PHP叫超文本预处理器
- 【小程序】通过scroll-view组件实现左右【滑动】列表
- CKS CKA CKAD 将终端更改为远程桌面
- Paramètres communs de matplotlib
- Three development trends of enterprise application from the perspective of the third technological revolution
猜你喜欢

SWT / anr problem - SWT causes kernel fuse deadlock

玻璃马赛克

Linux基础 —— CentOS7 离线安装 MySQL

What professional classification does the application of Internet of things technology belong to

Istio, ebpf and rsocket Broker: in depth study of service grid

Why is PHP called hypertext preprocessor

CKS CKA ckad change terminal to remote desktop

Matplotlib common settings

微信个人小商店一键开通助手小程序开发

Three development trends of enterprise application from the perspective of the third technological revolution
随机推荐
Distance measurement - Hamming distance
Microservice stability management
Notes on problems - /usr/bin/perl is needed by mysql-server-5.1.73-1 glibc23.x86_ sixty-four
Matplotlib常用设置
实在RPA:银行数字化,业务流程自动化“一小步”,贷款审核效率“一大步”
typescript枚举
The difference between timer and scheduledthreadpoolexecutor
认识线程
What professional classification does the application of Internet of things technology belong to
2022 crane driver (limited to bridge crane) examination questions and simulation examination
CADD course learning (3) -- target drug interaction
Experience of practical learning of Silicon Valley products
赵福全:短期解决保供,长期要打造安全、高效有韧性的供应链
Istio, ebpf and rsocket Broker: in depth study of service grid
Postgresql随手记(10)动态执行EXECUTING语法解析过程
玻璃马赛克
What is the difference between memory leak and memory overflow?
每日三题 6.30(2)
Matplotlib常用設置
Linux foundation - centos7 offline installation of MySQL