Redis 关闭持久化及关闭持久化后正确删除持久化之前的数据
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redis 关闭持久化及关闭持久化后正确删除持久化之前的数据相关的知识,希望对你有一定的参考价值。
去掉持久化
首先要确保你启动Redis加载的配置文件的路径是正确的
修改配置文件 redis.windows-service.conf
找到以下内容并设置 若无请添加
#save 900 1
#save 300 10
#save 60 10000
appendonly=no
save ""
如果之前存储了持久化的数据,发现删除了后重启服务数据还会恢复
来到Redis目录下删除dump.rdb即可。
dump.rdb 是redis 启动的时候会加载的数据文件。
在Redis中提供了两种 持久化功能
1. RDB持久化:
该机制是指在指定的时间间隔内将内存中的数据集快照写入磁盘。
这个机制是redis的默认持久化机制,在redis.conf配置文件当中,有
################################ SNAPSHOTTING #################################
#
# 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
save 900 1
save 300 10
save 60 10000
该机制默认15分钟有一次修改,6分钟内有10次修改,1分钟内有10000次修改,将会将快照数据集集中写入磁盘(即dump.rdb文件)
下面两个配置,设置了持久化文件的位置和文件名
# The filename where to dump the DB
dbfilename dump.rdb
# For default save/load DB in/from the working directory
# Note that you must specify a directory not a file name.
dir ./
2. AOF持久化:
该机制将以日志的形式记录服务器所处理的每一个写操作,在Redis服务器启动之初会读取该文件来重新构建数据库,以保证启动后数据库中的数据是完整的。
通过在redis.conf配置文件中将
appendonly no 改为yes就会开启AOF持久化功能,默认是no
############################## APPEND ONLY MODE ###############################
# By default Redis asynchronously dumps the dataset on disk. If you can live
# with the idea that the latest records will be lost if something like a crash
# happens this is the preferred way to run Redis. If instead you care a lot
# about your data and don‘t want to that a single record can get lost you should
# enable the append only mode: when this mode is enabled Redis will append
# every write operation received in the file appendonly.log. This file will
# be read on startup in order to rebuild the full dataset in memory.
#
# Note that you can have both the async dumps and the append only file if you
# like (you have to comment the "save" statements above to disable the dumps).
# Still if append only mode is enabled Redis will load the data from the
# log file at startup ignoring the dump.rdb file.
#
# The name of the append only file is "appendonly.log"
#
# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
# log file in background when it gets too big.
appendonly no
以上是关于Redis 关闭持久化及关闭持久化后正确删除持久化之前的数据的主要内容,如果未能解决你的问题,请参考以下文章