日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Redis的配置文件

發布時間:2025/1/21 数据库 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Redis的配置文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Redis的配置文件

1:持久化

  • 在規定的時間內,執行了多少次的操作,會持久化到文件rdb,aof

  • redis 是內存數據庫

  • 如果在900 s 內,有一個key 進行了修改,我們會進行持久化的操作

  • 如果在300 s 內,有十個key進行了修改,我們也會進行持久化的操作

  • 如果是 60 s 內,有10000key進行了修改,我們也會進行持久化的操作

save 900 1 save 300 10 save 60 10000

2:數據庫

# However if you have setup your proper monitoring of the Redis server # and persistence, you may want to disable this feature so that Redis will # continue to work as usual even if there are problems with disk, # permissions, and so forth. # 持久化如果出錯,在硬盤上,是否還要繼續工作 stop-writes-on-bgsave-error yes# Compress string objects using LZF when dump .rdb databases? # For default that's set to 'yes' as it's almost always a win. # If you want to save some CPU in the saving child set it to 'no' but # the dataset will likely be bigger if you have compressible values or keys. # 是否壓縮rdb文件,需要消耗一些CPU的資源 rdbcompression yes# Since version 5 of RDB a CRC64 checksum is placed at the end of the file. # This makes the format more resistant to corruption but there is a performance # hit to pay (around 10%) when saving and loading RDB files, so you can disable it # for maximum performances. # # RDB files created with checksum disabled have a checksum of zero that will # tell the loading code to skip the check. # 保存RDB文件的收,進行錯誤的檢查校驗 rdbchecksum yes# The filename where to dump the DB # 數據庫的名字 dbfilename dump.rdb# The working directory. # # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # # The Append Only File will also be created inside this directory. # # Note that you must specify a directory here, not a file name. # 工作路徑 dir ./

3:安全

  • 默認是沒有密碼的,需要自己去修改密碼

4:內存滿處理

**1、volatile-lru:**只對設置了過期時間的key進行LRU(默認值)

2、allkeys-lru : 刪除lru算法的key

**3、volatile-random:**隨機刪除即將過期key

**4、allkeys-random:**隨機刪除

5、volatile-ttl : 刪除即將過期的

6、noeviction : 永不過期,返回錯誤

# maxmemory-policy noeviction# LRU and minimal TTL algorithms are not precise algorithms but approximated # algorithms (in order to save memory), so you can tune it for speed or # accuracy. For default Redis will check five keys and pick the one that was # used less recently, you can change the sample size using the following # configuration directive. # # The default of 5 produces good enough results. 10 Approximates very closely # true LRU but costs a bit more CPU. 3 is very fast but not very accurate.

AOF

  • 默認是 不開啟的
  • 每秒執行一次
appendonly no# The name of the append only file (default: "appendonly.aof") appendfilename "appendonly.aof" # appendfsync always appendfsync everysec

5:RDB規則

  • save
  • flushall
  • 退出

優點

  • 適合于大規模的數據恢復
  • 對數據的完整性要求不要

缺點

  • 需要進行一定的時間間隔進程操作,如果redis意外宕機了,那么最后一次修改數據就沒有了

  • fork進程的時候,會占用一定的內存空間

總結

以上是生活随笔為你收集整理的Redis的配置文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。