1 The meaning of Rdb
Redis provides RDB persistence, which keeps the Redis database state in memory on disk to avoid accidental loss of data. RDB persistence can be performed either manually or periodically based on server configuration options, which can save the state of a database at a point in time to a RDB file. The Rdb file generated by the RDB persistence feature is a compressed binary file that enables you to restore the state of the database when the generated RDB file is created. 2 rdb file loading
RDB files are loaded automatically when the server is started, so there are no commands specifically for loading RDB files, and whenever the Redis server detects RDB files at startup, it automatically loads RDB files.
Because aof files are often updated more frequently than RDB files, the following conditions exist:
1 if the server has AOF persistence enabled, the server will use the AoF file as a priority to restore the state of the database.
2 The server will use the Rdb file to restore the database state only if the AOF persistence feature is turned off.
Command |
Characteristics |
SAVE |
When the command executes, the Redis server is blocked, so all command requests sent by the client are rejected when the Save command is executing. |
Bgsave |
The save work for the Bgsave command is performed by a subprocess, so the Redis server can still continue processing the client's command requests while the child process creates the Rdb file. Second, during the execution of the Bgsave command, the Save and Bgsave commands sent by the client are rejected by the server, and the server prevents the Save command and Bgsave from executing the rdbsave call simultaneously to prevent the parent and child processes from producing the competition conditions. |
3 Rdb File Components
1) Five-byte "Redis" string
2) Four-byte version number (db_version)
3 A byte of EOF constant
4) eight-byte checksum