Redis的持久化RDB

來源:互聯網
上載者:User

標籤:redis

dbfilename redis.db  //持久化的檔案
dir /home/redis/6379    //檔案所在目錄
save 900 1    // 900秒 修改一個key就儲存一次
save 300 10    // 300秒 修改10個key就儲存一次
save 60 10000    // 60秒 修改10000 個key就儲存一次
//上述3個save條件應該從下往上看,每個條件都是或的關係
rdbcompression yes        //啟用壓縮
rdbchecksum yes    //啟用校正和
stop-writes-on-bgsave-error yes    //在dump資料到磁碟時出現錯誤則終止redis的寫入



[[email protected] ~]# redis-server /etc/redis/6379.conf

[[email protected] 6379]# pwd
/home/redis/6379
[[email protected] 6379]# ll

[[email protected] 6379]# redis-cli
127.0.0.1:6379> set site www.baidu.com
OK


[[email protected] ~]# redis-benchmark -n 20000
[[email protected] 6379]# ll
total 124
-rw-r--r-- 1 root root 124100 May  5 13:37 redis.db
設定nosave一定要在redis.db檔案產生後,產生該檔案的條件是一定要到60秒(不到60秒不產生)
127.0.0.1:6379> set nosave www.123.com
OK

[[email protected] 6379]# pkill -9 redis
再次重新啟動redis
127.0.0.1:6379> get site
"www.baidu.com"


127.0.0.1:6379> get nosite
(nil)

本文出自 “技術部落格” 部落格,請務必保留此出處http://raytech.blog.51cto.com/7602157/1770578

Redis的持久化RDB

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.