preface

This is what I use to see for myself, no useful content, big guys see this can be launched to avoid wasting their study time

RDB

  • The snapshot is saved to a disk
  • The file suffix is dump.rdb

Snapshot generation Mode

  • save
    • The main process executes, blocking the Redis service until the RDB process is complete
  • bgsave
    • Fork creates a child process to perform RDB without affecting other Redis services
  • automation
    • The configuration file configures the persistence conditions that trigger Redis
      • Save M N: BgSave is triggered after n data changes within m seconds
  • A master-slave architecture
    • When synchronizing data, the slave sends sync to the host for synchronization, and the master performs bgSave

The advantages and disadvantages

  • Advantages:
    • Generate binary files, small memory footprint
    • Using disaster recovery, recovering big data is more efficient than AOF
  • Disadvantages:
    • Fork Data modified during RDB execution will not be saved and data will be lost

AOF

  • Store as an append file with the name append only File
  • Each modification is recorded and the recorded operation command is executed again upon the restart

synchronously

  • appendfsync always
    • AOF is written every time there is a data modification
  • appendfsync everysec
    • Synchronizes every second
  • appendfsync no
    • Not synchronized, scheduled by the operating system

Rewrite, rewrite

  • Rewrite can rewrite the AOF file to omit invalid commands and merge multiple duplicate commands
  • Trigger setting
    • Manual trigger
      • Call the bgrewriteaof command directly
    • Auto repeat
      • Auto-aof -rewrite-min-size: the minimum size of a file when aof rewriting is run. The default size is 64MB. When 64MB is reached, rewriting is triggered automatically
      • Auto-aof -rewrite-percentage: specifies the percentage of the size of the current AOF file to that of the last AOF file. If the percentage is reached, the aOF file will be rewritten
  • Rewrite after Redis4.0
    • Mixed mode is supported. The operation commands written into AOF are converted into binary compressed space in RDB persistence mode. When the AOF file reaches the rewriting trigger condition, it will be rewritten

The advantages and disadvantages

  • Advantages:
    • More secure data
  • Disadvantages:
    • AOF files are usually larger than RDB files

    • The recovery time is slower than that of RDB