redis配置文件解釋

protected-mode yes

默認情況下 redis 不是作爲守護進程運行的,如果你想讓它在後臺運行,你就把它改成 yes。
 當redis作爲守護進程運行的時候,它會寫一個 pid 到 /var/run/redis.pid 文件裏面。


port 6800

監聽端口號,默認爲 6379,如果你設爲 0 ,redis 將不在 socket 上監聽任何客戶端連接

tcp-backlog 511

# TCP 監聽的最大容納數量
#
# 在高併發的環境下,你需要把這個值調高以避免客戶端連接緩慢的問題。
# Linux 內核會一聲不響的把這個值縮小成 /proc/sys/net/core/somaxconn 對應的值,
# 所以你要修改這兩個值才能達到你的預期。

timeout 0

# 默認情況下,redis 在 server 上所有有效的網絡接口上監聽客戶端連接。
# 你如果只想讓它在一個網絡接口上監聽,那你就綁定一個IP或者多個IP。
#
# 示例,多個IP用空格隔開:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1
 
# 指定 unix socket 的路徑。
#
# unixsocket /tmp/redis.sock
# unixsocketperm 755
 
# 指定在一個 client 空閒多少秒之後關閉連接(0 就是不管它)

tcp-keepalive 300

# tcp 心跳包。
#
# 如果設置爲非零,則在與客戶端缺乏通訊的時候使用 SO_KEEPALIVE 發送 tcp acks 給客戶端。
# 這個之所有有用,主要由兩個原因:
#
# 1) 防止死的 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.
#
# A reasonable value for this option is 60 seconds.
# 推薦一個合理的值就是60秒

daemonize yes

# Redis默認是不作爲守護進程來運行的。你可以把這個設置爲"yes"讓它作爲守護進程來運行。

# 注意,當作爲守護進程的時候,Redis會把進程ID寫到 /var/run/redis.pid

supervised no
pidfile /var/run/redis_6379.pid

# 當redis作爲守護進程運行的時候,它會把 pid 默認寫到 /var/run/redis.pid 文件裏面,
# 但是你可以在這裏自己制定它的文件位置。

loglevel notice

# 定義日誌級別。
# 可以是下面的這些值:
# debug (適用於開發或測試階段)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (適用於生產環境)
# warning (僅僅一些重要的消息被記錄)

logfile ""

指定的日誌文件路徑


databases 16

# 設置數據庫的數目。
# 默認數據庫是 DB 0,你可以在每個連接上使用 select <dbid> 命令選擇一個不同的數據庫,
# 但是 dbid 必須是一個介於 0 到 databasees - 1 之間的值

always-show-logo yes


save 900 1
save 300 10
save 60 10000

################################ 快照 ################################
#
# 存 DB 到磁盤:
#
#   格式:save <間隔時間(秒)> <寫入次數>
#
#   根據給定的時間間隔和寫入次數將數據保存到磁盤
#
#   下面的例子的意思是:
#   900 秒內如果至少有 1 個 key 的值變化,則保存
#   300 秒內如果至少有 10 個 key 的值變化,則保存
#   60 秒內如果至少有 10000 個 key 的值變化,則保存
#  
#   注意:你可以註釋掉所有的 save 行來停用保存功能。
#   也可以直接一個空字符串來實現停用:
#   save ""

stop-writes-on-bgsave-error yes

# 默認情況下,如果 redis 最後一次的後臺保存失敗,redis 將停止接受寫操作,
# 這樣以一種強硬的方式讓用戶知道數據不能正確的持久化到磁盤,
# 否則就會沒人注意到災難的發生。
#
# 如果後臺保存進程重新啓動工作了,redis 也將自動的允許寫操作。
#
# 然而你要是安裝了靠譜的監控,你可能不希望 redis 這樣做,那你就改成 no 好了。

rdbcompression yes

# 是否在 dump .rdb 數據庫的時候使用 LZF 壓縮字符串
# 默認都設爲 yes
# 如果你希望保存子進程節省點 cpu ,你就設置它爲 no ,
# 不過這個數據集可能就會比較大

rdbchecksum yes

# 是否校驗rdb文件

dbfilename dump.rdb

# 設置 dump 的文件位置

dir ./

# 工作目錄
# 例如上面的 dbfilename 只指定了文件名,
# 但是它會寫入到這個目錄下。這個配置項一定是個目錄,而不能是文件名。

slave-serve-stale-data yes

# 當一個 slave 與 master 失去聯繫,或者複製正在進行的時候,
# slave 可能會有兩種表現:
#
# 1) 如果爲 yes ,slave 仍然會應答客戶端請求,但返回的數據可能是過時,
#    或者數據可能是空的在第一次同步的時候
#
# 2) 如果爲 no ,在你執行除了 info he salveof 之外的其他命令時,
#    slave 都將返回一個 "SYNC with master in progress" 的錯誤,

slave-read-only yes

# 你可以配置一個 slave 實體是否接受寫入操作。
# 通過寫入操作來存儲一些短暫的數據對於一個 slave 實例來說可能是有用的,
# 因爲相對從 master 重新同步數而言,據數據寫入到 slave 會更容易被刪除。
# 但是如果客戶端因爲一個錯誤的配置寫入,也可能會導致一些問題。
#
# 從 redis 2.6 版起,默認 slaves 都是隻讀的。
#
# Note: read only slaves are not designed to be exposed to untrusted clients
# on the internet. It's just a protection layer against misuse of the instance.
# Still a read only slave exports by default all the administrative commands
# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
# security of read only slaves using 'rename-command' to shadow all the
# administrative / dangerous commands.
# 注意:只讀的 slaves 沒有被設計成在 internet 上暴露給不受信任的客戶端。
# 它僅僅是一個針對誤用實例的一個保護層。

repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100

# 當 master 不能正常工作的時候,Redis Sentinel 會從 slaves 中選出一個新的 master,
# 這個值越小,就越會被優先選中,但是如果是 0 , 那是意味着這個 slave 不可能被選中。
#
# 默認優先級爲 100。

 requirepass xvw423GY32pc

設置redis的連接密碼


maxmemory 5368709120

 使用的最大內存

lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no


appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
maxmemory-policy volatile-lru

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章