08持久化操作RDB

当前Redis版本6.2.4

Redis提供了两种不同形式的持久化方式。

  • RDB(Redis DataBase)
  • AOF(Append Of File

一.RDB(Redis DataBase)

RDB:在指定的时间间隔内将内存中的数据集快照写入磁盘,也就是行话讲的Snapshot快照,它恢复时是将快照文件直接读到内存里。

在配置文件中有关RDB快照的配置

################################ SNAPSHOTTING  ################################

# Save the DB to disk.   //将数据库保存到磁盘
#
# save <seconds> <changes>
#
# Redis will save the DB if both the given number of seconds and the given  //如果给定的描述和给定的写操作数都达到给定值,Redis将保存数据库。
# number of write operations against the DB occurred.
#
# Snapshotting can be completely disabled with a single empty string argument  //使用一个空字符串参数可以完全禁用快照
# as in following example:
#
# save ""     //使用空字符完全禁用快照
#
# Unless specified otherwise, by default Redis will save the DB:  //除非另有规定,默认情况下Redis将保存数据库
#   * After 3600 seconds (an hour) if at least 1 key changed     //3600秒(一小时)后,如果至少有一个key发生了变化
#   * After 300 seconds (5 minutes) if at least 100 keys changed //300秒(5分钟)后,如果至少更改了100个键
#   * After 60 seconds if at least 10000 keys changed
#
# You can set these explicitly by uncommenting the three following lines.
#
# save 3600 1
# save 300 100
# save 60 10000

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
stop-writes-on-bgsave-error yes

# Compress string objects using LZF when dump .rdb databases?
# By default compression is enabled as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes

# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
rdbchecksum yes

# Enables or disables full sanitation checks for ziplist and listpack etc when
# loading an RDB or RESTORE payload. This reduces the chances of a assertion or
# crash later on while processing commands.
# Options:
#   no         - Never perform full sanitation
#   yes        - Always perform full sanitation
#   clients    - Perform full sanitation only for user connections.
#                Excludes: RDB files, RESTORE commands received from the master
#                connection, and client connections which have the
#                skip-sanitize-payload ACL flag.
# The default should be 'clients' but since it currently affects cluster
# resharding via MIGRATE, it is temporarily set to 'no' by default.
#
# sanitize-dump-payload no

# The filename where to dump the DB
dbfilename "dump.rdb"

# Remove RDB files used by replication in instances without persistence
# enabled. By default this option is disabled, however there are environments
# where for regulations or other security concerns, RDB files persisted on
# disk by masters in order to feed replicas, or stored on disk by replicas
# in order to load them for the initial synchronization, should be deleted
# ASAP. Note that this option ONLY WORKS in instances that have both AOF
# and RDB persistence disabled, otherwise is completely ignored.
#
# An alternative (and sometimes better) way to obtain the same effect is
# to use diskless replication on both master and replicas instances. However
# in the case of replicas, diskless is not always an option.
rdb-del-sync-files no

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir "/usr/local/redis-6.2.4/bin"

 

上一篇:Pytest(14) - allure参数:@allure.step()、allure.attach


下一篇:allure修改logo和内容标题