Persistence: Storing data in a device that is not lost after a power outage, usually a hard disk
How the RDB works:
After every n minutes or N writes, an RDB file is formed from the memory dump data, compressed , and placed in the backup directory (the red part can be configured by parameters)
RDB Snapshot Related parameters:
Save 1 #刷新快照到硬盘中, must meet the requirements of both participants trigger, that is, 900 seconds after at least 1 keywords change (3)
Save 300 10 # must be 300 seconds after at least 10 keywords changed (2)
Save 60 10000 # must be 60 seconds after at least 10,000 key words have changed, (1)
(all 3 options are masked, the RDB fails)
Stop-writes-on-bgsave-error Yes #后来存储错误停止写
Rdbcompression Yes #使用LZF压缩rdb文件
Rdbchecksum Yes #c存储和加载rdb文件时校验
Dbfilename Dump.rdb # setting RDB file name
Dir./# Set working directory, RDB file will be written to directory
The defect of the RDB
Between 2 save points, a power outage will lose 1-n minutes of data
For more granular requirements for persistence, Redis has added aof mode append only file
Working principle:
There is a redis-server process that has a rdbdump process that reaches the trigger condition in the work, calling the Rdbdump process. The trigger condition is monitored by the redis-server. Recovery is fast. Will lose data in a few minutes
Redis Note--rdb Snapshot persistence