当前位置:网站首页>Redis persistence (RDB and AOF)
Redis persistence (RDB and AOF)
2022-07-22 15:13:00 【Just number six Z】
Redis Persistence (RDB and AOF)
Redis Persistence
redis Is a memory database , If you do not save the database state in memory to disk , Then once the server process exits , The status of the database in the server will also send messages , therefore redis Provides persistence .
RDB(redis database)
What is? rdb?
In master-slave replication ,rdb It's a spare .
Writes a snapshot of a data set in memory to disk within a specified time interval , That's what jargon says snapshot snapshot , When it recovers, it reads the snapshot file directly into memory .
Sometimes in a production environment , We will back up this file .
Redis Will create... Separately (fork) A subprocess to persist , The data will be written to a temporary file first , When the persistence process is over , Replace the last persistent file with this temporary file . The whole process , The main process is not going to do anything IO Operation of the . This ensures extremely high performance . If large-scale data recovery is needed , And it's not very sensitive to the integrity of data recovery , that RDB The way is better than AOF It's more efficient .RDB The disadvantage of is that the data after the last persistence process may be lost .
Our default is RDB, In general, there is no need to modify .
rdb The saved file is dump.rdb, Snapshots can be configured in the configuration file !
dbfilename dump.rdb
rdb The trigger mechanism of
1.save When the rules are satisfied , Will automatically trigger rdb The rules
2. perform flushall command , It will trigger our rdb The rules
3. sign out redis, There will be rdb file
Also generated after backup dump.rdb file
How to restore rdb file ?
1. Only need to rdb The documents are on our redis Just start the directory ,redis It will be checked automatically when it is started dump.rdb Recover the data
2. Check where you want to store it
127.0.01:6379> config get dir
1) "dir"
2) "usr/local/bin" If it exists in this directory dump.rdb file , The data in it will be recovered automatically when it is started
Theoretically , The default configuration is enough for us .
advantage :
1. Suitable for large-scale data recovery
2. The requirement of data integrity is not high
shortcoming :
1. It takes a certain time interval to operate If redis Unexpected downtime , The last modified data is gone
2.fork Process time , It will occupy a certain amount of memory space
AOF(append only file)
Record all our orders ,history, When restoring, execute the file all over again !
Log each read and write operation , take Redis All instructions executed are recorded ( Reading operation does not record ), Only files can be added but not rewritten ,redis At the beginning of startup, it will read the file and rebuild the data , In other words ,redis In case of restart, execute the write instruction from the front to the back according to the contents of the log file to complete the data recovery .
Rewrite rule description
aof The default is unlimited appending of files , The file will get bigger and bigger
auto-aof-rewirte-percentage 100
auto-aof-rewirte-min-size 64mb
If aof File is larger than 64m. will fork A new process will rewrite our files .
AOF What is kept is appendonly.aof file
appendonly Not on by default . We need to configure it manually Change it to yes It opens. aof
restart redis It will take effect
If aof There is an error in the file , This is the time redis It can't start up , We need to fix aof file
redis Provides us with a tool redis-check-aof --fix
If the file is normal , Restart to recover .
advantage :
1. Every change is synchronized , The file will be more complete
2. Synchronize once per second , One second of data could be lost
3. No synchronization , The most efficient
shortcoming :
1. Relative to data files ,aof Far greater than rdb, The repaired data speed is low
2.aof It is also more efficient than rdb slow , So we redis The default configuration is rdb Persistence
边栏推荐
- How to make the signal of conductive slip ring better
- With no performance forecast, BOE is silent at this time?
- Zcmu--1925: HX & XH's game (C language)
- 10 baseline papers required for entry recommendation system
- Spark总结
- Cell isolation study - Worthington Clostridium protease program
- Leetcode 202. happy number (2022.07.21)
- Time of regular release under test
- Design of ads multi frequency power amplifier bias network
- 2022-07-18 子查询-优化exists场景的join查询优化器的处理
猜你喜欢
细胞分离研究丨Worthington梭菌蛋白酶方案
Worthington cell separation optimization system (including cell separation guide)
109. Ordered linked list transformation binary search tree ●●
Redis----三大特殊数据类型、事务、整合、配置文件、持久化rdb和aof、发布订阅、主从复制(哨兵模式)、缓存穿透和雪崩
2022-07-13 mysql/stonedb的快速子查询和慢子查询执行对比
弹性蛋白酶丨Worthington 核心酶详细参考资料
2022.7.11-7.17 AI industry weekly (issue 106): just try your best
Classification and application of slip rings
2022-07-13 mysql/stonedb子查询-优化器处理记录
687. Longest same value path ●●
随机推荐
Redis持久化(RDB和AOF)
弹性蛋白酶丨Worthington 核心酶详细参考资料
MySQL的锁机制:MyISAM 表锁、InnoDB行锁
Network layer protocol -------- IP
2022.7.11-7.17 AI industry weekly (issue 106): just try your best
Silicon Valley classroom notes (Part 2)
Simple use of Android kotlin
1. Openpyxl open workbook
Elastase Worthington core enzyme detailed reference
Myocardial xanthase -- characteristics of myocardial xanthase of Clostridium crenatum Worthington
1338. Halve the size of the array ●●
With no performance forecast, BOE is silent at this time?
论文阅读 | Point-Voxel CNN for Efficient 3D Deep Learning
Pytorch Deep Learning Practice - 1 - Overview
Introduction to relevant matters of PMP preparation guide
Cellulase preparation scheme of Worthington plant protoplast
2022-07-18 exists子查询的剔除遍历处理
定时的时间测试
[MySQL series] MySQL database foundation
这个sql怎么优化?