1. 程式人生 > >Redis配置檔案 redis.conf 解讀(一)

Redis配置檔案 redis.conf 解讀(一)

# Redis configuration file example
# redis配置檔案模板

# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:

# 引數單位使用須知:在需要對記憶體大小進行配置時,其通常可能以1k 5GB 4M等類似的形式進行指定
#
# 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.
# 對記憶體大小進行配置時,其單位不區分大小寫,例如1Gb 1GB 1gB所代表的都是相同的大小

################################## INCLUDES ###################################

# Include one or more other config files here. This is useful if you

# have a standard template that goes to all Redis server but also need
# to customize a few per-server settings. Include files can include
# other files, so use this wisely.
# 此處用於包含一個或者多個配置檔案。假如你在配置多個Redis時,絕大多數的配置相同,但每個
# Redis的配置還是有個體差異,這時你就適合使用include標籤;通過把相同的配置定義成一個外
# 部公共模板,用include標籤進行引入,以此來降低配置難度
#
# Notice option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
# 請注意,對於同一個配置項,Redis總是選擇最後一行的配置生效;因此,如果你希望配置檔案的
# 優先順序高於模板檔案,那麼請在配置檔案的第一行使用include
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
# 反之,如果你希望模板配置的優先順序更高,那麼就在配置檔案的最後一行使用include
#
# include /path/to/local.conf
# include /path/to/other.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.
# Redis預設為非後臺執行。當daemonize值為yes時,Redis將會在後臺執行,其程序資訊將會寫入
# /var/run/redis.pid檔案中;當daemonize值為no時,Redis將不採用後臺執行
daemonize yes

# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
# 當redis以後臺程式形式執行時,redis的程序id會預設寫入到/var/run/redis.pid檔案張巨集;在
# 此處你可以自定義需要程序id寫入的檔案及其路徑
pidfile /var/run/redis.pid

# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
# 此處定義連線埠,預設為6379;如果埠為0,那麼Redis不會監聽對應的TCP連線
port 6379

# TCP listen() backlog.
# TCP連線緩衝池
#
# In high requests-per-second environments you need an high backlog in order
# to avoid slow clients connections issues. Note that the Linux kernel
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
# 在高併發環境下,需要通過緩衝池來防止出現客戶端連線緩慢的問題。需要注意的是,Linux的內
# 核會通過/proc/sys/net/core/somaxconn和tcp_max_syn_backlog來影響到緩衝池的具體效果。
# 因此為了獲得理想的效果,請提高somaxconn和tcp_max_syn_backlog的值
tcp-backlog 511

# By default Redis listens for connections from all the network interfaces
# available on the server. It is possible to listen to just one or multiple
# interfaces using the "bind" configuration directive, followed by one or
# more IP addresses.
# 預設情況下,Redis監聽來自伺服器所有可行介面的連線;可以通過bind標籤使Redis只監聽一個
# 或多個指定的IP地址;bind標籤後可接一個或多個IP地址
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1

# Specify the path for the Unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
# unixsocker的路徑指向的檔案用於定義監聽的連線;此設定項沒有預設值,因此在沒有定義的情
# 況下,redis會預設監聽所有
#
# unixsocket /tmp/redis.sock
# unixsocketperm 755

# Close the connection after a client is idle for N seconds (0 to disable)
# 當一個客戶端已經斷開n秒後,自動斷開該連線(超時機制)
timeout 0

# TCP keepalive.
# TCP長連線
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
# 如果該配置值非零,則在不存在通訊的情況下使用SO_KEEPALIVE向客戶端傳送TCP ACKs,原因
# 如下:
#
# 1) Detect dead peers.
# 檢測連線是否死亡
# 2) Take the connection alive from the point of view of network
# equipment in the middle.
# 通過中間網路裝置的角度,使該連線長期處於存活狀態
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
# 在Linux中,通過指定的值(通常以秒為單位)定期向客戶端傳送ACKs,類似於心跳檢測;需要注意
# 的是,如果要關閉連線則需要消耗該值的兩倍的時間;在其他的核心上具體的單位以核心配置為準
#
# A reasonable value for this option is 60 seconds.
# 建議值為60
tcp-keepalive 0

# Specify the server verbosity level.
# 指定服務日誌級別
# This can be one of:
# 可以有以下取值:
# debug (a lot of information, useful for development/testing)
# debug(通常用於開發/測試)
# verbose (many rarely useful info, but not a mess like the debug level)
# verbose(簡化debug級別的日誌資訊,包含少量有用資訊)
# notice (moderately verbose, what you want in production probably)
# notice(通常用於生產環境)
# warning (only very important / critical messages are logged)
# warning(只記錄重要的警告資訊)
# 日誌級別
loglevel notice

# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
# 指定日誌檔案路徑和名稱;當為空字串時,Redis將以預設地址進行輸出;注意:如果使用標準
# 輸出且以後臺程序形式執行,預設輸出到/dev/null
logfile ""

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled為yes時,日誌將被寫入到系統日誌中;同時可以根據自己的需要有選擇性的更新
# 其他的syslog引數
# syslog-enabled no

# Specify the syslog identity.
# 指定日誌在系統日誌中的標識
# syslog-ident redis

# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# 指定系統日誌的裝置;必須為某個使用者,或者介於LOCAL0-LOCAL17
# syslog-facility local0

# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
# 設定Redis資料庫的數量;預設使用第0個Redis資料庫,你可以在連線中使用SELECT <dbid>來
# 指定每一個連線究竟使用哪一個資料庫
databases 16