Redis持久化策略
阿新 • • 發佈:2020-09-14
1、RDB:快照
- 時間點問題:比如 8:00開始快照,8:10分才快照成功,那麼快照的是8:00還是8:10分的資料
- 方式:
- save 【命令】
- bgsave 【命令】- fork[linux]另起一個子程序,資料隔離(寫時複製)進行資料快照
- save <seconds> <changes> 【配置-注意:這邊實際上呼叫的是bgsave命令】
參考配置檔案中的說明:大概指的是指定時間內至少有多少個數據改變
################################ 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 10keys 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
ps:涉及點-父子程序之間,資料隔離&CopyOnWrite(僅寫時複製)
2、AOF:日誌