标签:moni 直接 flush 数据安全 orm log hang 并且 point
redis.conf文件
RDB是整个内存的压缩过的Snapshot,RDB的数据结构,可以配置复合的快照触发条件,
默认
是1分钟内改了1万次,
或5分钟内改了10次,
或15分钟内改了1次。
b.如果想禁用RDB持久化的策略,只要不设置任何save指令,或者给save传入一个空字符串参数也可以
194 # Note: you can disable saving completely by commenting out all "save" lines. 195 # 196 # It is also possible to remove all the previously configured save 197 # points by adding a save directive with a single empty string argument 198 # like in the following example: 199 # 200 # save "" 202 save 900 1 203 save 300 10 204 save 60 10000
set key value1 save 此时立马执行,形成最新的dump文件
# 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
yes:出错了就立即停止
# 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
dbfilename
默认生成的rdb文件名
# The filename where to dump the DB dbfilename dump.rdb
dir
# Note that you must specify a directory here, not a file name. dir ./
实战测试:
修改配置文件
200 # save "" 202 save 900 1 203 save 120 10 204 save 60 10000
两分钟10次操作
之后会生成一个dump.rdb文件,具体生成文件的默认名请修改:dbfilename
进行复制(备份)
模拟事故:
此时直接删除所有的数据
此时再次重新登陆则是会显示为空,即是存在dump.rdb文件
APPEND ONLY MODE追加
appendonly:默认开关状态,可以同时和RDB一起开着
# AOF and RDB persistence can be enabled at the same time without problems. # If the AOF is enabled on startup Redis will load the AOF, that is the file # with the better durability guarantees. # # Please check http://redis.io/topics/persistence for more information. appendonly no 默认是关着的
appendfilename:默认的文件名
# The name of the append only file (default: "appendonly.aof") appendfilename "appendonly.aof"
appendfsync
# no: don‘t fsync, just let the OS flush the data when it wants. Faster. # always: fsync after every write to the append only log. Slow, Safest. # everysec: fsync only one time every second. Compromise. always:同步持久话每次发生数据变更立即记录到磁盘,性能比较差但是数据完整性好 everysec:出场默认的推荐的,异步操作,每秒记录,如果一秒内宕机,有数据丢失
# More details please check the following article: # http://antirez.com/post/redis-persistence-demystified.html # If unsure, use "everysec". # appendfsync always appendfsync everysec
# If you have latency problems turn this to "yes". Otherwise leave it as # "no" that is the safest pick from the point of view of durability. no-appendfsync-on-rewrite no
# This base size is compared to the current size. If the current size is # bigger than the specified percentage, the rewrite is triggered. Also # you need to specify a minimal size for the AOF file to be rewritten, this # is useful to avoid rewriting the AOF file even if the percentage increase # is reached but it is still pretty small. # Specify a percentage of zero in order to disable the automatic AOF # rewrite feature. auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb
# Please check http://redis.io/topics/persistence for more information. appendonly yes
创造性的意外事件
此时RDB和AOF文件都在
此时启动Redis
在dump.rdb文件完整的情况下,appendonly.aof文件出错,说明后者的优先级大于前者
那么此时的处理方式是:
redis-check-aof --fix appendonly.aof
再次重新启动:
Redis配置文件(2)SNAPSHOTTING快照/APPEND ONLY MODE追加
标签:moni 直接 flush 数据安全 orm log hang 并且 point
原文地址:https://www.cnblogs.com/Mrchengs/p/10053560.html