Redis --redis.conf詳解

redis.conf詳解redis

# 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不會在後臺一直運行。若是你須要它一直運行,修改以下參數爲 'yes'
#注意:'yes'狀況下,redis會寫一個pid(進程標識符)文件到 /var/run/redis.pid下面。
daemonize no

# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
#你能夠指定一個自定義的pid文件在這裏
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.
#redis默認的監聽端口是6379,咱們能夠自定義監聽端口
#若是設置監聽端口爲0,則redis再也不監聽TCP鏈接
port 6379

# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
#若是你綁定了IP,則redis監聽該IP的鏈接;若是你不綁定,則它監聽全部的鏈接
# 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.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 755
# Close the connection after a client is idle for N seconds (0 to disable)
#設置客戶端鏈接超時的時間,單位爲秒,即 當客戶端空閒的時間超過N秒後關閉鏈接
#0表示不指定超時時間
timeout 0

# Set server verbosity to 'debug'
# it 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)
#指定日誌級別
#它是以下選項中的一個
#debug(記錄不少信息,適用於開發/測試階段)
#verbose(記錄有用的信息,不像debug那樣產生不少信息)
#notice(記錄的信息比verbose少點,儘量輸出你想要的信息,適用於上線運行階段)
#warning(僅僅是很是重要的/緊急的信息被記錄)
loglevel verbose

# Specify the log file name. Also 'stdout' 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
#指定log文件的地址,'stdout'常常被使用
#redis會執行標準的輸出,當後臺進程一直運行時,redis將輸出 /dev/null
logfile stdout

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
#當以下參數設置成yse的時候,redis會記錄系統日誌,你也能夠修改系統日誌參數來知足你的須要
# syslog-enabled no

# Specify the syslog identity.
#指定日誌標識符
# syslog-ident redis

# Specify the syslog facility.  Must be USER or between LOCAL0-LOCAL7.
#指定系統設備,必須是USER或是LOCAL0-LOCAL7之間的值
# 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
#設置數據庫的個數
#默認是數據庫是DB0,你能夠在每個鏈接上使用 select<dbid>來選擇一個不一樣的數據庫
#可是dbid的數字位於 0 ~ databased-1 之間
databases 16

###########快照###########
保存數據到磁盤  
格式:save<間隔時間(S)> <寫入次數>  
根據給定的時間間隔和寫入操做次數將數據保存到磁盤  
示例:  
900秒後至少有1個key值發生變化,則保存  
300秒後至少有10個key值發生變化,則保存  
60秒後至少有1000個key值發生變化,則保存  
save 900 1  
save 300 10  
save 60 10000  
備註:若是註釋掉,則不作內存數據持久化;若是是將redis做爲cache使用,則不須要開啓持久化功能。  

在進行鏡像備份時,是否使用LZF壓縮  
rdbcompression yes  

鏡像備份文件的文件名  
dbfilename dump.rdb  

數據鏡像備份文件存放的路徑,數據將寫入到這個目錄,使用上述defilename名字。固然依賴文件也將被建立在這個目錄。注意這裏你是指定一個目錄路徑,而不是一個文件名稱。  
dir ./  

#############主從複製############  
主從複製。使用從服務去產生一個實例,該實例是redis服務的複製版本。使用從服務通常是保存數據或是監聽端口等。  
#設置該數據庫爲其它主數據庫的從
# slaveof <masterip> <masterport>  

#指定與主數據庫鏈接時須要的密碼驗證  
# masterauth <master-password>  

當slave失去與master的鏈接,或slave一直與master進行復制工做時,  
slave有以下兩種方式響應客戶端請求:  
1>slave-serve-stale-data yes 時(默認狀況),從數據庫將一直響應客戶端請求,可能數據過時了或者數據爲空。  
2>slave-serve-stale-data no時,從數據庫將響應錯誤信息指令 SYNC with master in progress,info和slaveof指令除外。  
#slave-serve-stale-data yes  

當slave與master失聯時,它每隔 10s(默認是10S,咱們能夠指定其它時間) ping master。  
# repl-ping-slave-period 10  

設置超時時間,這個時間必須大於repl-ping-slave-period值  
# repl-timeout 60  

###########安全#############  
#設置鏈接主數據庫的 密碼  
# requirepass foobared  

############ 限制 ###########
相關文章
相關標籤/搜索