REdis之RDB配置問題


RDB配置:
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error no
rdbcompression yes
rdbchecksum yes
repl-diskless-sync no
aof-use-rdb-preamble no
rdb-save-incremental-fsync yes

影響:
易生成REdis客戶端的連接超時。

建議:
如果已經開啟了AOF,可關閉RDB,即將save參數值設置為空:save "";
或者調大save參數,人工控制save執行時間點,將save放在空閑時段,
但問題實際仍然存在,只是影響減少,同時需要調長client與REdis的超時時長。
如果是REdis-5.0或以上版本,可以設置配置項rdb-save-incremental-fsync值為yes,
以降低save時的影響,但之下的版本不支持rdb-save-incremental-fsync。

理由:
在生成RDB時,易導致客戶端訪問超時。
截至REdis-5.0版本,如果開啟了AOF,
在進程啟動時仍然只會加載AOF文件,並不會使用RDB文件,
所以不生成RDB也是安全的。

缺點:
AOF文件不支持重啟后的增量復制(可理解為斷點續復制),
而從REdis-4.0開始RDB支持增量復制。
在不久的將來,AOF可能也會支持重啟時的增量復制。
一個比較簡單的實現AOF支持增量復制方法,
新增命令SETREPL,在每次fsync之前寫入一筆SETREPL命令,
該命令帶兩個參數,一是replid,二是offset,
這樣重啟回放時,可以象RDB那樣恢復replid和offset,
而只需要對REdis做小量改動。

保存RDB日志示例:
62820:M 01 Apr 18:15:57.097 * 10000 changes in 60 seconds. Saving...
62820:M 01 Apr 18:15:57.103 * Background saving started by pid 69409
69409:C 01 Apr 18:15:57.427 * DB saved on disk
69409:C 01 Apr 18:15:57.433 * RDB: 2 MB of memory used by copy-on-write
62820:M 01 Apr 18:15:57.504 * Background saving terminated with success

62820:M 01 Apr 18:16:58.098 * 10000 changes in 60 seconds. Saving...
62820:M 01 Apr 18:16:58.104 * Background saving started by pid 75882
75882:C 01 Apr 18:16:58.426 * DB saved on disk
75882:C 01 Apr 18:16:58.433 * RDB: 2 MB of memory used by copy-on-write
62820:M 01 Apr 18:16:58.505 * Background saving terminated with success

62820:M 01 Apr 18:17:59.104 * 10000 changes in 60 seconds. Saving...
62820:M 01 Apr 18:17:59.110 * Background saving started by pid 82326
82326:C 01 Apr 18:17:59.419 * DB saved on disk
82326:C 01 Apr 18:17:59.426 * RDB: 2 MB of memory used by copy-on-write
62820:M 01 Apr 18:17:59.510 * Background saving terminated with success


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM