Redis RDB persistence principle

rdb endurance placement

# Time strategy, which means that if there is a write command in 900s, it will trigger a snapshot, which can be understood as a backup
save 900 1
save 300 10 # means that there are 10 writes in 300s, and a snapshot
save 60 will be generated 10000
# redis servercron is similar to linux crontab, it is executed every 100 milliseconds by default

# File name
dbfilename dump.rdb

# If there is a persistence error, whether the main process stops writing
stop-writes-on-bgsave-error yes

# Whether to compress
rdbcompression yes

# Whether to check
rdbchecksum yes during import

# File save path
dir /usr/local/redis-4.0.14

 

  • the meaning of save

    In the actual production environment, the read and write requests at each time period are definitely not balanced. For this reason, redis provides a way to trigger a backup to disk based on the number of key operations per unit time. We can freely customize under what circumstances to trigger the backup. This function balances performance. And data security

  • There are two types of RDB persistence triggers in Redis: manual trigger and Redis timing trigger

    • For RDB persistence, manual triggering can be used:

      • save: Will block the current Redis server until the persistence is complete, and it should be prohibited online.

      • bgsave: This trigger method will fork a child process, and the child process is responsible for the persistence process, so blocking will only occur when the child process is fork

  • The automatic triggering scene mainly has the following points

    • According to our save m nconfiguration rules automatically trigger

    • When the slave node is fully copied, the master node sends the rdb file to the slave node to complete the copy operation, and the master node will trigger bgsave

    • Execution debug reloadtime

    • Execution shutdown, if not turned aof, will trigger

  • Disable RDB

    • Just write on the last line of save: save ""

Guess you like

Origin blog.csdn.net/qq_41023026/article/details/89739234