Redis 2 redis 配置文件redis.conf

在對redis 配置文件進行修改的時候要進行備份

https://raw.githubusercontent.com/antirez/redis/3.0/redis.conf

一: 對單位的定義

# Redis配置文件樣例

# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.

首先是對單位的介紹 對大小寫不敏感, 支持的bytes,不支持bit

二:INCLUDES

# Include one or more other config files here.
...
# include /path/to/local.conf
# include /path/to/other.conf

通過includes 包含,redis.conf 作爲總閘,可以包含其他的配置文件

三:GENERAL

通用的標準化配置

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no  		 # 在自己使用的時候要將no 改爲yes 

#默認情況下,redis不作爲守護進程運行。如果需要,請使用“是”。
#注意redis會在後臺監控時在/var/run/redis.pid中寫入一個pid文件
在使用的時候將 no 變爲yes,使redis 編程一個守護進程運行
port 6379
默認運行接口
tcp-backlog 511
設置tcp 的backlog ,backlog 是一個鏈接隊列(連接總和),在高併發的情況下需要一個高的backlog 值 來避免客戶端的鏈接問題
backlog 隊列總和= 爲未完成三次握手隊列+已經完成三次握手隊列

在自己的單機測試,學習的過程中不用管他(自己學習也不需要一個千萬級的連接數)
# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
當客戶端空閒多少時間之後將客戶端域redis 的鏈接斷開,0 表示不關閉一直保持鏈接
TCP-keepalive 0
單位爲秒,表示一段時間間隔對鏈接情況進行檢測,查看是否keepalive ,0 表示一直不檢測
# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel notice

redis 的日誌級別 : development/testing 使用debug 四個日誌級別 往下級別越高,打印的信息越少,產品投入生產
之後建議使用notic/warning
logfile ""
日誌文件的名字,可以是空的字符串,redis 就會在控制檯有一個標準的輸出
# syslog-enabled no
是否把redis 的日誌輸入到系統日誌 默認 no 

# syslog-ident redis
指定系統中redis 的日誌標識 默認爲redis 

四:snapshoptting(快照)

五:replication(複製)

六:security(安全)

在linux 環境下是直接進入redis ,並不需要密碼登錄
redis 是架在linux 服務器上的,你進入linux 就表示你的安全級別是夠的,所以就認爲是可以直接用的,不用密碼


#查看密碼 : 默認密碼爲空
config get requirepass

#設置密碼
config set requirepass "密碼"

# Require clients to issue AUTH <PASSWORD> before processing any other
# 如果設置了密碼,那麼在進行操作之前 就要 進行密碼輸入
auth <PASSWORD>

七: limits 限制

一些連接,緩存,內存的大小限制

#連接限制
# maxclients 10000    
#內存分配
# maxmemory <bytes>
#過期清除策略
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
#內存大小是有限的,當你的內存達到最大之後,你將採取那種方式對內存進行移除管理(移除那些數據):

# The default is:
# 默認設置: 永不過期 (實際的生產過程中,不可用)
# maxmemory-policy noeviction

數據清除策略:

  1. volatile-lru : 使用lru (最近最少使用策略) 刪除數據。但是隻針對設置了過期時間的key
  2. allkeys-lru : 使用lru 策略刪除數據,對於任何鍵
  3. volatile-random : 隨機刪除。只針對設置了過期時間的key
  4. allkeys-random :隨機刪除,針對任何鍵
  5. volatile-ttl : 刪除ttl 最小的鍵(刪除快過期的鍵)。但是隻針對設置了過期時間的key
  6. noeviction : 永不過期(在實際的生產中不會使用),針對寫操作,無法寫入就會返回錯誤。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章