1. 程式人生 > >Redis 關閉持久化及關閉持久化後正確刪除持久化之前的數據

Redis 關閉持久化及關閉持久化後正確刪除持久化之前的數據

async 找到 family 如果 file end and redis服務器 where

去掉持久化

首先要確保你啟動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 關閉持久化及關閉持久化後正確刪除持久化之前的數據