当前位置:网站首页>Redis persistence
Redis persistence
2022-07-24 07:03:00 【Bustling.】
Single point Redis There are many problems , Therefore, persistence is required Redis:

One 、RDB Persistence
RDB Full name Redis Database Backup file(Redis Data backup file ), It's also called Redis Data snapshot . Simply put, it is to record all the data in memory to disk . When Redis After instance failure and restart , Read snapshot file from disk , Restore data . The snapshot file is called RDB file , By default, it is saved in the current running Directory .
Execution opportunity 、
1、save command :

2、bgsave command :

3、 During shutdown :
Redis During shutdown, it will be executed once save command , Realization RDB Persistence .
4、 Trigger RDB Conditions :
Redis There is an internal trigger RDB The mechanism of , Can be in redis.conf Found in file , The format is as follows :

RDB Other configurations of can also be in redis.conf Set in file :

principle 、
bgsave At the beginning fork The main process gets the child process , Child processes share the memory data of the main process . complete fork After reading the memory data and writing RDB file .fork It's using copy-on-write technology :

summary 、

Two 、AOF Persistence
AOF Its full name is Append Only File( Additional documents ).Redis Every write command processed will be recorded in AOF file , It can be regarded as a command log file .

The configuration file 、
AOF The default is off , Need modification redis.conf Configuration file to open AOF:

AOF The frequency of command recording can also be through redis.conf File to match :

Comparison of three recording frequency modes :

File rewriting 、
Because it's a record command ,AOF The document will compare with RDB The files are much bigger . and AOF Will record for the same key Multiple write operations , But only the last write operation makes sense . Through execution bgrewriteaof command , It can make AOF The file performs the rewriting function , Achieve the same effect with the least number of commands .

Redis It will also be automatically rewritten when the threshold is triggered AOF file . The threshold can also be in redis.conf Middle configuration :

3、 ... and 、RDB And AOF contrast

边栏推荐
猜你喜欢

Jsonobject is sorted in A-Z order of key

Prediction of advertising investment and sales based on regression analysis -- K neighborhood, decision tree, random forest, linear regression, ridge regression

极客星球丨 字节跳动一站式数据治理解决方案及平台架构

Getting started with redis

XXL execute node error log swiping

Metaltc5.0 realizes webrtc version IPC of Junzheng pure C

Geek planet ByteDance one stop data governance solution and platform architecture

sojson jsjiami.com. V6 crawler JS reverse
![[wechat applet] understand conditional rendering, list rendering and wxss template style](/img/97/cb78efcbcfe1a598da87751c482a98.png)
[wechat applet] understand conditional rendering, list rendering and wxss template style

Requirements already satisfied: and read timed out. problem solving methods appear during the installation of snownlp package
随机推荐
【学习笔记】url输入到页面展现中发生了什么?
Redis basic type - hash
济南人社已签1W+电子劳动合同,法大大助力HR数字化
After grouping, return to the last record group in each group_ Use of concat
Tensorflow Einstein function
[lvgl] API functions for setting, changing and deleting styles of components
一个AI玩41个游戏,谷歌最新多游戏决策Transformer综合表现分是DQN的两倍
[lvgl layout] grid layout
You don't have to waste your life on others' standards
Redis.conf details
STM32基于hal库的adc以DMA的多通道采样以及所遇问题解决
Job search memo
上传excel文件
STM32 ADC based on Hal library uses DMA multi-channel sampling and solves the problems encountered
Day (0~6) represents the starting position of the first day of each month, stop represents the number of days of each month, and there are two blank spaces between each day. Input different days and s
Gangster escape 3
Sealos packages and deploys kubesphere container platform
【学习笔记】从汇编看 a+++a与 a+a++的区别
sojson jsjiami.com. V6 crawler JS reverse
找工作备忘