当前位置:网站首页>Redis的两种持久化机制RDB和AOF的原理和优缺点
Redis的两种持久化机制RDB和AOF的原理和优缺点
2022-07-06 09:20:00 【快醒醒鸭今天你编程了吗?】
下面是Redis里面两种持久化机制的原理的优缺点也挺重要的:
Redis本身是基于Key-Value结构的内存数据库,Redis为了避免Redis故障导致数据丢失的一个问题提供了RDB和AOF两种持久化的机制
- RDB是通过快照的方式实现持久化机制的,也就是说会根据快照的一个触发条件把内存里面的数据快照写入到磁盘里面以二进制的压缩文件的方式进行存储RDB快照方式有很多如下:
- 执行bgsave命令触发异步快照,执行save命令触发同步快照,两者的区别:同步快照会阻塞客户端的执行指令
- 根据redis.conf文件里面的配置,自动触发bgsave
- 主从复制的时候会触发

- AOF持久化是一种近乎实时的方式,把Redis Server执行的事务命令进行追加存储,就是客户在执行一个数据变更的操作,Redis就会把这样一个命令追加到aof的缓冲区里面,然后再把缓冲区里面的数据写入到磁盘的aof文件里面,最终什么时候 真正把数据持久化到磁盘的aof文件里面,是根据磁盘的刷盘策略来决定的,另外AOF这种指令追加的一个方式会造成AOOF文件过大带来明显的IO性能问题,所以Redis针对这样一个情况提供了AOF重写机制,当AOF文件大小达到某个值的时候就会把这个文件里面的相同的指令进行压缩


RDB和AOF的优缺点:
- RDB是每隔一段时间触发持久化,因此数据安全性低,AOF可以做到实时持久化,数据安全性较高
- RDB文件默认采用压缩的方式持久化,AOF存储的是执行指令,所以RDB在数据恢复的时候性能比AOF要好
优缺点还要看当前具体的应用场景!!!!
边栏推荐
- [Topic terminator]
- Conceptual model design of the 2022 database of tyut Taiyuan University of Technology
- 学编程的八大电脑操作,总有一款你不会
- Redis cache obsolescence strategy
- TYUT太原理工大学2022数据库题库选择题总结
- Wei Pai: the product is applauded, but why is the sales volume still frustrated
- 3. Number guessing game
- 13 power map
- 【九阳神功】2019复旦大学应用统计真题+解析
- Network layer 7 protocol
猜你喜欢

Introduction and use of redis

抽象类和接口

Cloud native trend in 2022

Application architecture of large live broadcast platform

MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series

Conceptual model design of the 2022 database of tyut Taiyuan University of Technology

One article to get UDP and TCP high-frequency interview questions!

(super detailed II) detailed visualization of onenet data, how to plot with intercepted data flow

4. Binary search

继承和多态(上)
随机推荐
继承和多态(上)
IPv6 experiment
1.初识C语言(1)
167. Sum of two numbers II - input ordered array - Double pointers
First acquaintance with C language (Part 2)
西安电子科技大学22学年上学期《基础实验》试题及答案
6. Function recursion
TYUT太原理工大学2022软工导论考试题型大纲
2.初识C语言(2)
【九阳神功】2020复旦大学应用统计真题+解析
3.C语言用代数余子式计算行列式
The latest tank battle 2022 full development notes-1
MYSQL索引钟B-TREE ,B+TREE ,HASH索引之间的区别和应用场景
凡人修仙学指针-1
3. C language uses algebraic cofactor to calculate determinant
Pit avoidance Guide: Thirteen characteristics of garbage NFT project
View UI plus released version 1.3.0, adding space and $imagepreview components
Differences and application scenarios between MySQL index clock B-tree, b+tree and hash indexes
最新坦克大战2022-全程开发笔记-3
View UI plus released version 1.2.0 and added image, skeleton and typography components