美文网首页
REDIS----配置文件----SNAPSHOTTING

REDIS----配置文件----SNAPSHOTTING

作者: JuMinggniMuJ | 来源:发表于2020-06-01 20:45 被阅读0次

SNAPSHOTTING部分:

1.触发条件:
# Save the DB on disk:
#   save <seconds> <changes>
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#   Note: you can disable saving completely by commenting out all "save" lines.
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#   save ""
save 900 1
save 300 10
save 60 10000

如果既定的秒数和给定的针对数据库的写操作次数均发生,则将保存数据库,在下面的示例中,行为将是保存:1)在900秒(15分钟)后,如果至少更改了1个键;2)300秒(5分钟)后,如果至少更改了10个按键;3)60秒后,如果至少更改了10000个键.您可以通过注释掉所有“保存”行来完全禁用保存。也可以通过添加带有单个空字符串参数的save指令来删除所有先前配置的保存点
这是持久化的触发条件,建议新手不要贸然更改持久化触发条件

2.报错停止写入:
# 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

默认情况下,如果启用了RDB快照(至少一个保存点)并且最新的后台保存失败,则Redis将停止接受写入。 这将使用户(以一种强硬的方式)意识到数据无法正确地持久存储在磁盘上,否则,可能没人会注意到并且会发生一些灾难,如果后台保存过程将再次开始工作,则Redis将自动允许再次写入。但是,如果您设置了对Redis服务器和持久性的适当监视,则可能要禁用此功能,以便即使磁盘,权限等出现问题,Redis也将继续照常工作。
这个是一个很有意思的配置项,有点类似于别拿豆包不当干粮的配置项,通俗的说就是,我持久化失败了你redis也玩不了,你持久化好了我让redis马上正常工作,但是你如果设置了其他的监视,不需要我了,那么就当没有我,把我设置成no

3.数据压缩:
# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' 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

指定存储至本地数据库时是否压缩数据,默认是yes,redis采用LZF压缩,如果为了节省CPU时间可以关闭该选项,但会导致数据库文件变的巨大.

4.持久化数据数量校验:
# 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

从RDB版本5开始,CRC64校验数位于文件末尾。 这使该格式更能抵抗损坏,但是在保存和加载RDB文件时会降低性能(约10%),因此可以禁用该格式以获得最佳性能。在禁用校验和的情况下创建的RDB文件的校验和为零,这将指示加载代码跳过该校验。

5.文件名称:
# The filename where to dump the DB
dbfilename dump.rdb
6.文件目录:
# 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 ./

数据库将被写入该目录内,文件名使用“ dbfilename”配置指令在上面指定。也将在此目录中创建附加文件。请注意,您必须在此处指定目录,而不是文件名。

相关文章

网友评论

      本文标题:REDIS----配置文件----SNAPSHOTTING

      本文链接:https://www.haomeiwen.com/subject/drfezhtx.html