Redis配置文件翻譯

簡(jiǎn)述

看源碼之前,當(dāng)然先看工具的配置文件。Redis配置文件是英文注釋,讀起來(lái)晦澀難懂。那么今天就先來(lái)翻譯以下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:
# 單位的說(shuō)明:需要標(biāo)示內(nèi)存大小時(shí),可以使用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.
# 單位不區(qū)分大小寫,所以1GB 1Gb 1gB時(shí)相同的含義

################################## 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.
# Include表示有一個(gè)或多個(gè)其他配置文件。您如果有適用于所有Redis服務(wù)器的模版,但還需要自定義每個(gè)服務(wù)器的設(shè)置。
# 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.
# 請(qǐng)注意"include"不會(huì)被"CONFIG REWRITE"命令重寫,即使是admin或者redis哨兵。因?yàn)镽edis會(huì)將最后讀取到的值做為配置文件的值,
# 因此最好將include文件放在開(kāi)頭,避免運(yùn)行時(shí)覆蓋配置。
# CONFIG REWRITE:命令對(duì)啟動(dòng)中的Redis服務(wù)器所指定的redis.conf配置文件進(jìn)行修改。
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
# 如果您希望include文件覆蓋掉配置文件,請(qǐng)將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.
# 默認(rèn)Redis不以守護(hù)進(jìn)程的方式運(yùn)行。如果需要開(kāi)啟修改為"yes"。
# 注意,redis開(kāi)啟守護(hù)進(jìn)程時(shí),會(huì)將pd寫入到/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.
# 以守護(hù)進(jìn)程運(yùn)行時(shí),Redis默認(rèn)會(huì)將pid寫入/var/run/redis.pid文件中。您可以在這里指定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.
# 接收指定端口的連接,默認(rèn)是6379。如果端口是0,Redis將無(wú)法監(jiān)聽(tīng)TCP的連接。

port 6379

# TCP listen() backlog.
#
# 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.
# 在每秒高請(qǐng)求的環(huán)境中,您需要提高backlog的配置,來(lái)避免客戶端連接速度慢的問(wèn)題。
# 注意,Linux內(nèi)核會(huì)截?cái)噙@個(gè)值,因此同時(shí)修改/proc/sys/net/core/somaxconn和tcp_max_syn_backlog的值,
# 來(lái)獲得期待的效果。
# tcp-backlog:在TCP連接三次握手中,客戶端首次向服務(wù)端發(fā)送的syn請(qǐng)求會(huì)被redis使用隊(duì)列緩存起來(lái),這個(gè)隊(duì)列就是tcp-backlog,
# 當(dāng)隊(duì)列長(zhǎng)度超過(guò)511時(shí),會(huì)將其丟棄,客戶端會(huì)認(rèn)為網(wǎng)絡(luò)丟包未收到響應(yīng)而進(jìn)行重傳。
# tcp-backlog設(shè)置過(guò)大會(huì)導(dǎo)致隊(duì)列存儲(chǔ)請(qǐng)求過(guò)多占用大量?jī)?nèi)存,客戶端很長(zhǎng)時(shí)間無(wú)法接收到響應(yīng),觸發(fā)超時(shí)重傳。
# tcp-backlog設(shè)置過(guò)小會(huì)導(dǎo)致客戶端丟包率頻繁,重傳頻繁造成網(wǎng)絡(luò)擁塞。

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.
# 默認(rèn)Redis監(jiān)聽(tīng)所有能夠鏈接服務(wù)器的網(wǎng)絡(luò)鏈接。可以使用"bind"配置指令只監(jiān)聽(tīng)一個(gè)或多個(gè)接口,后面可以跟一個(gè)或多個(gè)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.
# 指定明確的unix socket鏈接的地址。沒(méi)有默認(rèn)設(shè)置,因此沒(méi)有設(shè)置的話Redis將不會(huì)監(jiān)聽(tīng)unix socket。
#
# unixsocket /tmp/redis.sock
# unixsocketperm 755

# Close the connection after a client is idle for N seconds (0 to disable)
# 客戶端空閑N秒后鏈接關(guān)閉(0表示禁用)

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:
# 如果不是0,會(huì)使用SO_KEEPALIVE在沒(méi)有數(shù)據(jù)傳輸?shù)那闆r下向客戶端發(fā)送TCP的確認(rèn)。有如下兩個(gè)好處:
#
# 1) Detect dead peers.
# 1)檢測(cè)鏈接是否死掉。
# 2) Take the connection alive from the point of view of network
#    equipment in the middle.
# 2)從中間的網(wǎng)絡(luò)設(shè)備的角度看待鏈接。(類似鏈接池,需要鏈接就從鏈接池中獲取,而不是關(guān)閉再打開(kāi)鏈接)
#
# 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上,指定的值(單位秒)是用于發(fā)送ACK的時(shí)間周期。
# 請(qǐng)注意,關(guān)閉鏈接需要兩倍的時(shí)間周期。
# 在其他內(nèi)核上,時(shí)間周期取決于內(nèi)核配置。
#
# A reasonable value for this option is 60 seconds.
# 這里合理的值為60秒

tcp-keepalive 0

# Specify the server verbosity level.
# 指定服務(wù)器詳細(xì)級(jí)別。
# This can be one of:
# 以下可選情況之一:
# debug (a lot of information, useful for development/testing)
# debug(大量新秀,針對(duì)開(kāi)發(fā)/測(cè)試)
# verbose (many rarely useful info, but not a mess like the debug level)
# verbose(大量的有用信息,但不像debug級(jí)別那樣混亂)
# notice (moderately verbose, what you want in production probably)
# notice(一般的信息,可以在生產(chǎn)中使用)
# warning (only very important / critical messages are logged)
# warning(只記錄非常重要和關(guān)鍵的消息)

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日志進(jìn)行標(biāo)準(zhǔn)輸出。
# 請(qǐng)注意,如果使用標(biāo)準(zhǔn)日志輸出,且是守護(hù)進(jìn)程,則日志會(huì)輸出到/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.
# 要啟用系統(tǒng)日志的記錄,只需要"syslog-enabled"設(shè)置為yes,并根據(jù)需要設(shè)置其他ssylog參數(shù)。
#
# syslog-enabled no

# Specify the syslog identity.
# 指定系統(tǒng)日志標(biāo)記。
#
# syslog-ident redis

# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# 指定系統(tǒng)日志工具。必須是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
# 設(shè)置數(shù)據(jù)庫(kù)編號(hào)。默認(rèn)數(shù)據(jù)庫(kù)是DB 0,您可以使用SELECT <bdid>針對(duì)每個(gè)鏈接選擇不同的數(shù)據(jù)庫(kù),其中
# dbid的編號(hào)是在0和'databases'設(shè)置值之間。
#
databases 16

################################ SNAPSHOTTING  ################################
#
# Save the DB on disk:
# 將DB保存在磁盤上:
#
#   save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#   如果給定的秒數(shù)和對(duì)數(shù)據(jù)庫(kù)的修改操作數(shù)兩個(gè)條件同時(shí)滿足,則都會(huì)觸發(fā)保存數(shù)據(jù)庫(kù)。
#
#   In the example below the behaviour will be to save:
#   下面的示例中會(huì)觸發(fā)保存:
#
#   after 900 sec (15 min) if at least 1 key changed
#   900秒(15分鐘)后,如果有1個(gè)key被修改
#
#   after 300 sec (5 min) if at least 10 keys changed
#   300秒(5分鐘)后,如果有10個(gè)key被修改
#
#   after 60 sec if at least 10000 keys changed
#   60秒后,如果有10000個(gè)key被修改
#
#   Note: you can disable saving at all commenting all the "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#   也可以通過(guò)添加帶有單個(gè)空字符串的save指令,刪除以前的保存點(diǎn),如下所示:
#   save ""

save 900 1
save 300 10
save 60 10000

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
# 在默認(rèn)情況下,如果啟用了RDB快照(至少一個(gè)保存點(diǎn)),并且最新的保存失敗,Redis將停止接收寫入。
# 這會(huì)讓用戶意識(shí)到數(shù)據(jù)沒(méi)有正確的保存在磁盤上(這是非常強(qiáng)硬的),否則沒(méi)有正確的保存磁盤沒(méi)有被人注意到,這將會(huì)發(fā)生一些災(zāi)難;
# If the background saving process will start working again Redis will
# automatically allow writes again.
# 如果保存過(guò)程中Redis再次運(yùn)行,RDB將會(huì)允許再次寫入。
# 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.
# 如果您已經(jīng)設(shè)置了對(duì)Redis服務(wù)器和持久化的正確性監(jiān)視,則需要禁用此功能來(lái)保證即使在磁盤、權(quán)限等方面出現(xiàn)問(wèn)題時(shí),Redis仍然能正常工作。
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 databases何時(shí)使用LZF壓縮存儲(chǔ)字符串對(duì)象?
# 默認(rèn)是值是"yes",因?yàn)檫@總是成功的。
# 如果您想要保留一些CPU,請(qǐng)將其設(shè)置為"no",但是數(shù)據(jù)集可能會(huì)更大,即使有壓縮空間的值。
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 5版本之后CRC64校驗(yàn)被放置在文件末尾。
# 這種格式更能抵抗損壞,但保存和加載RDB文件時(shí),性能會(huì)受到影響(約10%),因此您可以禁用它來(lái)獲得性能最大化。
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
# 禁用檢查文件會(huì)校驗(yàn)RDB文件是否存儲(chǔ)檢查值,這將告訴加載代碼跳過(guò)檢查。
rdbchecksum yes

# The filename where to dump the DB
# 存儲(chǔ)數(shù)據(jù)庫(kù)的文件名稱。
dbfilename dump.rdb

# The working directory.
# 工作目錄。
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
# 使用上面"dbfilename"配置的文件,將會(huì)寫入到此目錄。
# The Append Only File will also be created inside this directory.
# aof文件也將在此目錄中創(chuàng)建
# Note that you must specify a directory here, not a file name.
# 請(qǐng)注意,您必須在此處指定目錄,而不是名稱。
dir ./

################################# REPLICATION #################################

# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. Note that the configuration is local to the slave
# so for example it is possible to configure the slave to save the DB with a
# different interval, or to listen to another port, and so on.
# 主從復(fù)制。使用slaveof讓Redis實(shí)例復(fù)制另一臺(tái)Redis服務(wù)。
# 請(qǐng)注意,配置的是本地從機(jī),因此可以將從機(jī)間的不同保存,或者監(jiān)聽(tīng)另一個(gè)端口,等等。
# slaveof <masterip> <masterport>

# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the slave to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the slave request.
# 如果主機(jī)器有密碼保護(hù)(使用"requirepass"配置指令)可以在啟動(dòng)同步復(fù)制之前進(jìn)行身份驗(yàn)證,否則主機(jī)器將拒絕請(qǐng)求。
# masterauth <master-password>

# When a slave loses its connection with the master, or when the replication
# is still in progress, the slave can act in two different ways:
# 當(dāng)從機(jī)器與主機(jī)器失去連接時(shí),但復(fù)制仍在進(jìn)行中,從機(jī)可以以兩種不同的方式工作:
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
#    still reply to client requests, possibly with out of date data, or the
#    data set may just be empty if this is the first synchronization.
# 1)如果"slave-serve-stale-data"設(shè)置的是yes(默認(rèn)值),則從服務(wù)器仍將回答客戶端的請(qǐng)求,
#    客戶端可能會(huì)請(qǐng)求過(guò)時(shí)的數(shù)據(jù),也可能請(qǐng)求到空的數(shù)據(jù)集,如果是第一次進(jìn)行同步的話。
# 2) if slave-serve-stale-data is set to 'no' the slave will reply with
#    an error "SYNC with master in progress" to all the kind of commands
#    but to INFO and SLAVEOF.
# 2)如果"slave-serve-stale-data"設(shè)置為no,則從機(jī)器將對(duì)除"INFO"和"SLAVEOF"命令之外的所有命令回復(fù)錯(cuò)誤"SYNC with master in progress"
slave-serve-stale-data yes

# You can configure a slave instance to accept writes or not. Writing against
# a slave instance may be useful to store some ephemeral data (because data
# written on a slave will be easily deleted after resync with the master) but
# may also cause problems if clients are writing to it because of a
# misconfiguration.
# 您可以配置從實(shí)例是否接收寫入。
# 針對(duì)從實(shí)例的寫入可能有助于存儲(chǔ)一些臨時(shí)數(shù)據(jù)(因?yàn)閷懭霃膶?shí)例,但從實(shí)例同步主實(shí)例數(shù)據(jù)后會(huì)被刪除),
# 但如果由于客戶端配置錯(cuò)誤而寫入數(shù)據(jù),會(huì)出現(xiàn)問(wèn)題。
# Since Redis 2.6 by default slaves are read-only.
# 因此Redis2.6之后默認(rèn)情況下從機(jī)是只讀的。
# 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.
# 注意:只讀從機(jī)設(shè)計(jì)不允許暴露在不受信任的客戶端上。
# 它只是一個(gè)防止實(shí)例誤用的保護(hù)層。
# 默認(rèn)情況下,只讀從機(jī)仍會(huì)響應(yīng)所有命令,如CONFIG、DEBUG等。
# 您可以使用"rename-command"來(lái)隱藏所有的管理和危險(xiǎn)的命令,從而提高只讀叢機(jī)的安全性。
slave-read-only yes

# Slaves send PINGs to server in a predefined interval. It's possible to change
# this interval with the repl_ping_slave_period option. The default value is 10
# seconds.
# 從服務(wù)器以設(shè)定的間隔時(shí)間向服務(wù)器發(fā)送ping??梢?repl_ping_slave_period"配置修改間隔時(shí)間。默認(rèn)間隔是10秒。
# repl-ping-slave-period 10

# The following option sets the replication timeout for:
# 從以下角度設(shè)置復(fù)制超時(shí)時(shí)間:
# 1) Bulk transfer I/O during SYNC, from the point of view of slave.
# 2) Master timeout from the point of view of slaves (data, pings).
# 3) Slave timeout from the point of view of masters (REPLCONF ACK pings).
#
# It is important to make sure that this value is greater than the value
# specified for repl-ping-slave-period otherwise a timeout will be detected
# every time there is low traffic between the master and the slave.
# 務(wù)必確保該值大于"repl-ping-slave-period"的值,否則每次主設(shè)備從設(shè)備之間的同步的通信數(shù)量較少時(shí)都會(huì)被檢測(cè)到超時(shí)。
# repl-timeout 60

# Disable TCP_NODELAY on the slave socket after SYNC?
#
# If you select "yes" Redis will use a smaller number of TCP packets and
# less bandwidth to send data to slaves. But this can add a delay for
# the data to appear on the slave side, up to 40 milliseconds with
# Linux kernels using a default configuration.
# 如果選擇"yes",Redis將使用較少的TCP數(shù)據(jù)包和較少的網(wǎng)絡(luò)貸款向從服務(wù)器發(fā)送數(shù)據(jù)。
# 但這會(huì)明顯增加從機(jī)的數(shù)據(jù)延遲,如果使用linux內(nèi)核的默認(rèn)配置,延遲能達(dá)到40毫秒。
# If you select "no" the delay for data to appear on the slave side will
# be reduced but more bandwidth will be used for replication.
# 如果您選擇"no",從機(jī)明顯的數(shù)據(jù)延遲將減少,但主從復(fù)制將使用更多網(wǎng)絡(luò)帶寬。
# By default we optimize for low latency, but in very high traffic conditions
# or when the master and slaves are many hops away, turning this to "yes" may
# be a good idea.
# 默認(rèn)情況下我們會(huì)優(yōu)化低延遲,但在流量非常高的情況下,或者主節(jié)點(diǎn)和從節(jié)點(diǎn)數(shù)據(jù)之間有很大差異時(shí),將這項(xiàng)選擇為"yes"是個(gè)好的方案。
repl-disable-tcp-nodelay no

# Set the replication backlog size. The backlog is a buffer that accumulates
# slave data when slaves are disconnected for some time, so that when a slave
# wants to reconnect again, often a full resync is not needed, but a partial
# resync is enough, just passing the portion of data the slave missed while
# disconnected.
# 設(shè)置復(fù)制集的backlog大小。這個(gè)backlog會(huì)緩存,從機(jī)斷開(kāi)后一段時(shí)間后的累積數(shù)據(jù),因此當(dāng)從機(jī)想要重新連接時(shí),
# 通常不需要完全重新同步,只需要部分的重新同步就足夠了,此時(shí)只傳遞斷開(kāi)連接時(shí)從機(jī)丟失的部分?jǐn)?shù)據(jù)。
# The biggest the replication backlog, the longer the time the slave can be
# disconnected and later be able to perform a partial resynchronization.
# backlog值越大,則從機(jī)器可以斷開(kāi)的時(shí)間就越長(zhǎng),重新連接之后執(zhí)行部分重新同步。
# The backlog is only allocated once there is at least a slave connected.
# 至少有一個(gè)從機(jī)連接時(shí),才會(huì)分配backlog空間。
# repl-backlog-size 1mb

# After a master has no longer connected slaves for some time, the backlog
# will be freed. The following option configures the amount of seconds that
# need to elapse, starting from the time the last slave disconnected, for
# the backlog buffer to be freed.
# 主機(jī)器不再連接從機(jī)器一段時(shí)間后,backlog空間將被釋放。以下配置是最后一次從機(jī)器斷開(kāi)連接時(shí)到開(kāi)始釋放積壓的緩沖區(qū)所需要的時(shí)間秒數(shù)。
# A value of 0 means to never release the backlog.
# 這個(gè)值為0表示,永遠(yuǎn)不釋放backlog。
# repl-backlog-ttl 3600

# The slave priority is an integer number published by Redis in the INFO output.
# It is used by Redis Sentinel in order to select a slave to promote into a
# master if the master is no longer working correctly.
# 從屬優(yōu)先級(jí)是Redis中INFO命令中輸出的一個(gè)整數(shù)。Redis Sentinel使用它來(lái)選擇一個(gè)從機(jī)器,以便主機(jī)器故障時(shí),將從機(jī)器升級(jí)為主機(jī)器。
# A slave with a low priority number is considered better for promotion, so
# for instance if there are three slaves with priority 10, 100, 25 Sentinel will
# pick the one with priority 10, that is the lowest.
# 優(yōu)先級(jí)分?jǐn)?shù)較低的從機(jī)器被認(rèn)為更適合升級(jí),例如有三個(gè)優(yōu)先級(jí)分?jǐn)?shù)為10,100,25的從機(jī)器,Sentinel將選擇優(yōu)先級(jí)分?jǐn)?shù)為10的從機(jī),因?yàn)檫@是延遲最低的。
# However a special priority of 0 marks the slave as not able to perform the
# role of master, so a slave with priority of 0 will never be selected by
# Redis Sentinel for promotion.
# 然而,特殊的優(yōu)先級(jí)分?jǐn)?shù)為0的從機(jī)器將無(wú)法擔(dān)任主機(jī)器的角色,因此Redis Sentinel將永遠(yuǎn)不會(huì)選擇優(yōu)先級(jí)分?jǐn)?shù)為0的從機(jī)器進(jìn)行升級(jí)。
# By default the priority is 100.
# 默認(rèn)情況下,優(yōu)先級(jí)為100。
slave-priority 100

# It is possible for a master to stop accepting writes if there are less than
# N slaves connected, having a lag less or equal than M seconds.
# 如果連接的從機(jī)器少于N個(gè),且從機(jī)器延遲時(shí)間必須小于或等于M秒,否則主機(jī)器將停止接受寫入。
# The N slaves need to be in "online" state.
# 這個(gè)N表示從機(jī)器需要處于"在線"狀態(tài)。
# The lag in seconds, that must be <= the specified value, is calculated from
# the last ping received from the slave, that is usually sent every second.
# 這個(gè)延遲秒數(shù),必須<=指定的時(shí)間,是根據(jù)從機(jī)器接收最后一次ping計(jì)算得出,ping通常每秒發(fā)送一次。
# This option does not GUARANTEES that N replicas will accept the write, but
# will limit the window of exposure for lost writes in case not enough slaves
# are available, to the specified number of seconds.
# 這個(gè)選項(xiàng)不能保證復(fù)制副本接受寫入,但將在沒(méi)有足夠的從機(jī)器可用時(shí),將隱藏寫入的窗口在指定的時(shí)間內(nèi)(秒為單位)。
# For example to require at least 3 slaves with a lag <= 10 seconds use:
# 如下例,要求至少3個(gè)從機(jī)器,且延遲時(shí)間<=10秒:
# min-slaves-to-write 3
# min-slaves-max-lag 10
#
# Setting one or the other to 0 disables the feature.
# 將一個(gè)或另一個(gè)設(shè)置為0,將禁用該功能。
# By default min-slaves-to-write is set to 0 (feature disabled) and
# min-slaves-max-lag is set to 10.
# 默認(rèn)情況下,min-slaves-to-write是0(功能已經(jīng)禁用),min-slaves-max-lag是10。

################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
# 要求客戶端在發(fā)送其它命令之前發(fā)送AUTH <PASSWORD>。在不信任他人能夠訪問(wèn)運(yùn)行中的redis服務(wù)器,這將很實(shí)用。
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
# 為了向后兼容,并且大多數(shù)人不需要auth(例如,他們運(yùn)行在自己的服務(wù)器上)。
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
# 警告:由于Redis速度非常快,外部用戶可以每秒150K密碼進(jìn)行嘗試。這意味著您應(yīng)該使用非常復(fù)雜的密碼,否則很容易被破解。
# requirepass foobared

# Command renaming.
# 命令重命名。
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.
# 可以在公共(共享)環(huán)境中更改危險(xiǎn)命令。例如,CONFIG命令可以被重命名為難以猜測(cè)的內(nèi)容,它仍然可以用于內(nèi)部的工具找到,
# 但普通的客戶端不可用。
# Example:
# 例子:
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possible to completely kill a command by renaming it into
# an empty string:
# 而且將命令重命名為空字符串,也可以完全終止命令:
# rename-command CONFIG ""
#
# Please note that changing the name of commands that are logged into the
# AOF file or transmitted to slaves may cause problems.
# 請(qǐng)注意,更改記錄AOF文件或數(shù)據(jù)傳輸從服務(wù)器的命令,可能會(huì)導(dǎo)致問(wèn)題。
################################### LIMITS ####################################

# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
# 設(shè)置同時(shí)連接客戶端的最大數(shù)量。默認(rèn)情況下此限制為10000個(gè)客戶端,
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.然而Redis服務(wù)器無(wú)法對(duì)進(jìn)程允許的最大限制進(jìn)行配置,因此允許的最大客戶端數(shù)為當(dāng)前
# 允許打開(kāi)的文件數(shù)減去32(由于Redis服務(wù)器預(yù)留一些供內(nèi)部使用的文件描述符)。
# maxclients 10000

# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys
# according to the eviction policy selected (see maxmemory-policy).
# 不要使用超過(guò)指定大小的內(nèi)存。
# 當(dāng)達(dá)到內(nèi)存限制時(shí),Redis將根據(jù)所選的淘汰策略嘗試刪除key(請(qǐng)查閱maxmemory-policy)。
#
# If Redis can't remove keys according to the policy, or if the policy is
# set to 'noeviction', Redis will start to reply with errors to commands
# that would use more memory, like SET, LPUSH, and so on, and will continue
# to reply to read-only commands like GET.
# 如果Redis無(wú)法根據(jù)策略刪除key,或者策略設(shè)置為"noeviction",Redis將對(duì)使用更多內(nèi)存命令
# 進(jìn)行錯(cuò)誤回復(fù),如SET、LPUSH等等,并繼續(xù)對(duì)只讀命令進(jìn)行回復(fù),如GET。
#
# This option is usually useful when using Redis as an LRU cache, or to set
# a hard memory limit for an instance (using the 'noeviction' policy).
# 當(dāng)Redis作為L(zhǎng)RU緩存或?yàn)閷?shí)例設(shè)置固定內(nèi)存限制時(shí),此選項(xiàng)通常很有用(使用"noeviction"策略)。
#
# WARNING: If you have slaves attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the slaves are subtracted
# from the used memory count, so that network problems / resyncs will
# not trigger a loop where keys are evicted, and in turn the output
# buffer of slaves is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
# 警告:如果連接到的從機(jī)器打開(kāi)maxmemory設(shè)置,則從機(jī)器的使用內(nèi)存中減去為從機(jī)器提供數(shù)據(jù)的緩沖區(qū)大小,
# 這樣網(wǎng)絡(luò)問(wèn)題/重新同步將不會(huì)觸發(fā)key循環(huán)淘汰,反之,從機(jī)器的輸出緩沖區(qū)滿了會(huì)觸發(fā)更多的key淘汰刪除,
# 以此類推,直到數(shù)據(jù)庫(kù)完全被清空。
#
# In short... if you have slaves attached it is suggested that you set a lower
# limit for maxmemory so that there is some free RAM on the system for slave
# output buffers (but this is not needed if the policy is 'noeviction').
# 簡(jiǎn)而言之,如果連接了從機(jī)器建議您設(shè)置較低的maxmemory,以便系統(tǒng)上有一些可用RAM用于從機(jī)器輸出緩沖區(qū)
#(但如果策略為"noeviction",則不需要這么做)。
#
# maxmemory <bytes>

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
# MAXMEMORY 策略:當(dāng)內(nèi)存達(dá)到maxmemory時(shí),Redis將從如何選擇性刪除。您可以從以下五種中進(jìn)行選擇:
# 
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# volatile-lru -> 使用LRU算法刪除有過(guò)期時(shí)間的key
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# allkeys-lru -> 使用LRU算法刪除任意的key
# volatile-random -> remove a random key with an expire set
# volatile-random -> 隨機(jī)刪除帶有過(guò)期時(shí)間的key
# allkeys-random -> remove a random key, any key
# allkeys-random -> 隨機(jī)刪除key,任意key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# volatile-ttl -> 刪除即將過(guò)期的key(類似TTL)
# noeviction -> don't expire at all, just return an error on write operations
# noeviction -> 從不過(guò)期,可能返回一個(gè)寫錯(cuò)誤。
# 
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are not suitable keys for eviction.
# 注意:對(duì)于上述策略,當(dāng)沒(méi)有合適的鍵淘汰時(shí),Redis將在寫入操作時(shí)返回錯(cuò)誤。
#
#       At the date of writing this commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is:
# 這個(gè)默認(rèn)值為:
#
# 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.
# LRU和TTL不是精確算法,而是近似算法(為了節(jié)省內(nèi)存),因此可以調(diào)整來(lái)提高速度或精度。默認(rèn)情況下,
# Redis將檢查5個(gè)key并選擇最近使用的key,您可以使用以下配置更改樣本大小。
#
# 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.
# 默認(rèn)值為5會(huì)產(chǎn)生足夠好的結(jié)果。10非常接近真實(shí)的LRU,但需要更多的CPU。3很快,但不是很準(zhǔn)確。
#
# maxmemory-samples 5

############################## APPEND ONLY MODE ###############################

# By default Redis asynchronously dumps the dataset on disk. This mode is
# good enough in many applications, but an issue with the Redis process or
# a power outage may result into a few minutes of writes lost (depending on
# the configured save points).
# 默認(rèn)情況下,Redis將數(shù)據(jù)異步轉(zhuǎn)存儲(chǔ)到磁盤上。這種模式在許多應(yīng)用程序中已經(jīng)足夠好了,但Redis進(jìn)程出現(xiàn)問(wèn)題
# 或斷電可能會(huì)導(dǎo)致幾分鐘的寫丟失(取決于配置的保存點(diǎn))。
#
# The Append Only File is an alternative persistence mode that provides
# much better durability. For instance using the default data fsync policy
# (see later in the config file) Redis can lose just one second of writes in a
# dramatic event like a server power outage, or a single write if something
# wrong with the Redis process itself happens, but the operating system is
# still running correctly.
# 這個(gè)Append Only File是另一種持久化模式,提供了更好的持久化。例如,默認(rèn)的數(shù)據(jù)fsync策略(請(qǐng)參閱
# 后面的配置文件部分),Redis可能會(huì)在服務(wù)器斷電之類的重大事故中丟失一秒的寫入,或者在Redis進(jìn)程本身
# 發(fā)生故障時(shí)丟失一次寫入,但操作系統(tǒng)仍然能夠正常運(yùn)行。
#
# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
# AOF和RDB持久化可以同時(shí)啟用,不會(huì)出現(xiàn)問(wèn)題。如果Redis啟動(dòng)時(shí)啟用AOF,Redis將加載AOF,這文件具有
# 更好的持久化保存。
#
# Please check http://redis.io/topics/persistence for more information.
# 請(qǐng)求查看了解更多信息http://redis.io/topics/persistence。

appendonly no

# The name of the append only file (default: "appendonly.aof")
# append only file名稱(默認(rèn)"appendonly.aof")

appendfilename "appendonly.aof"

# The fsync() call tells the Operating System to actually write data on disk
# instead to wait for more data in the output buffer. Some OS will really flush 
# data on disk, some other OS will just try to do it ASAP.
# fsync()調(diào)用告訴操作系統(tǒng)進(jìn)行磁盤寫入,而不是在輸出緩沖區(qū)等待更多的數(shù)據(jù)。有些操作系統(tǒng)會(huì)真正的刷新磁盤,
# 而另一些操作系統(tǒng)則會(huì)盡快刷盤。
#
# Redis supports three different modes:
# Redis支持的三種模式:
#
# no: don't fsync, just let the OS flush the data when it wants. Faster.
# no:不執(zhí)行fsync,讓操作系統(tǒng)在需要時(shí)刷新數(shù)據(jù)即可,更快。
# always: fsync after every write to the append only log . Slow, Safest.
# always:每次寫入追加日志后進(jìn)行fsync,很慢,最安全。
# everysec: fsync only one time every second. Compromise.
# everysec:fsync操作每秒進(jìn)行一次。妥協(xié)(折中)。
#
# The default is "everysec", as that's usually the right compromise between
# speed and data safety. It's up to you to understand if you can relax this to
# "no" that will let the operating system flush the output buffer when
# it wants, for better performances (but if you can live with the idea of
# some data loss consider the default persistence mode that's snapshotting),
# or on the contrary, use "always" that's very slow but a bit safer than
# everysec.
# 默認(rèn)值是"everysec",因?yàn)檫@通常是速度和安全之間的最佳折中。這是由您來(lái)決定的,如果可以放寬到"no",
# 這會(huì)讓操作系統(tǒng)在它想要的時(shí)候刷新緩沖區(qū),來(lái)獲得更好的性能(但如果您能容忍一些數(shù)據(jù)丟失的話,考慮使用
# 快照的方式持久化),或者相反,使用"always"這是非常慢的,但比"everysec"安全一些。
#
# More details please check the following article:
# 更多詳細(xì)信息請(qǐng)查看以下文章
# http://antirez.com/post/redis-persistence-demystified.html
#
# If unsure, use "everysec".
# 如果不確定,請(qǐng)使用"everysec"。

# appendfsync always
appendfsync everysec
# appendfsync no

# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
# 當(dāng)AOF fsync策略為always或者everysec,并后臺(tái)保存進(jìn)程(后臺(tái)保存或AOF重寫)正在對(duì)磁盤執(zhí)行大量I/O時(shí),
# 在某些配置的linux中,Redis可能會(huì)在fsync()調(diào)用阻塞太長(zhǎng)時(shí)間。請(qǐng)注意,目前還沒(méi)有解決此問(wèn)題的方案,因?yàn)?# 即使在不同的線程中執(zhí)行fsync,也會(huì)阻止我們調(diào)用同步寫入。
#
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
# 為了緩解此問(wèn)題,可以使用以下選項(xiàng),以防止BGSAVE或BGREWRITEAOF時(shí)主進(jìn)程中調(diào)用fsync()。
# 
#
# This means that while another child is saving, the durability of Redis is
# the same as "appendfsync none". In practical terms, this means that it is
# possible to lose up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
# 這意味著另一個(gè)子線程在存儲(chǔ)時(shí),Redis持久化與"appendfsync none"相同,實(shí)際上這意味著在最壞的
# 情況下,可能會(huì)丟失多大30秒的日志(使用默認(rèn)linux配置)。
# 
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.
# 如果您由延遲問(wèn)題,請(qǐng)將此項(xiàng)設(shè)置為"yes"。否則請(qǐng)保留"no",從持久化角度來(lái)看,這是最安全的選擇。

no-appendfsync-on-rewrite no

# Automatic rewrite of the append only file.
# Redis is able to automatically rewrite the log file implicitly calling
# BGREWRITEAOF when the AOF log size grows by the specified percentage.
# 自動(dòng)重寫append only file。
# 當(dāng)AOF日志大小達(dá)到指定大小時(shí),Redis能夠隱性的調(diào)用BGREWRITEAOF自動(dòng)重寫日志文件。
#
# This is how it works: Redis remembers the size of the AOF file after the
# latest rewrite (if no rewrite has happened since the restart, the size of
# the AOF at startup is used).
# 它的工作原理是:Redis會(huì)記錄最后一次寫入(如果重新啟動(dòng)為發(fā)生寫入,則使用啟動(dòng)時(shí)AOF)。
#
# This base size is compared to the current size. If the current size is
# bigger than the specified percentage, the rewrite is triggered. Also
# you need to specify a minimal size for the AOF file to be rewritten, this
# is useful to avoid rewriting the AOF file even if the percentage increase
# is reached but it is still pretty small.
# 將此基本大小與當(dāng)前大小進(jìn)行比較。如果當(dāng)前大小大于指定的百分比,則會(huì)觸發(fā)重寫。此外,您還需要為
# 重寫AOF文件指定最小大小,這對(duì)于避免重寫AOF文件非常有用,即使達(dá)到增加的百分比,但仍然非常小。
#
# Specify a percentage of zero in order to disable the automatic AOF
# rewrite feature.
# 指定0的百分比禁用AOF重寫功能。

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

################################ LUA SCRIPTING  ###############################

# Max execution time of a Lua script in milliseconds.
# Lua腳本的最大執(zhí)行時(shí)間毫秒。
#
# If the maximum execution time is reached Redis will log that a script is
# still in execution after the maximum allowed time and will start to
# reply to queries with an error.
# 如果達(dá)到最大執(zhí)行時(shí)間,Redis腳本將在允許的最大執(zhí)行時(shí)間后仍然執(zhí)行,并開(kāi)始回復(fù)帶有錯(cuò)誤的查詢。
#
# When a long running script exceed the maximum execution time only the
# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be
# used to stop a script that did not yet called write commands. The second
# is the only way to shut down the server in the case a write commands was
# already issue by the script but the user don't want to wait for the natural
# termination of the script.
# 當(dāng)長(zhǎng)時(shí)間運(yùn)行的腳本超過(guò)最大執(zhí)行m命令的時(shí)間時(shí),只有SCRIPT KILL和SHUTDOWN NOSAVE命令可用。
# 第一個(gè)命令可用于停止當(dāng)前尚未調(diào)用寫入命令的腳本。第二個(gè)命令是在腳本已經(jīng)發(fā)出寫入命令但用戶不想
# 等待腳本自然終止的情況下關(guān)閉服務(wù)器的唯一方法。
#
# Set it to 0 or a negative value for unlimited execution without warnings.
# 將其設(shè)置為0,便是在沒(méi)有警告的情況下無(wú)限執(zhí)行。
lua-time-limit 5000

################################ REDIS CLUSTER  ###############################
#
# Normal Redis instances can't be part of a Redis Cluster; only nodes that are
# started as cluster nodes can. In order to start a Redis instance as a
# cluster node enable the cluster support uncommenting the following:
# 普通Redis實(shí)例不能作為Redis集群的一部分。只有作為集群節(jié)點(diǎn)啟動(dòng)才能成功節(jié)點(diǎn)。要將Redis實(shí)例作為
# 集群節(jié)點(diǎn)啟動(dòng),請(qǐng)啟用集群支持取消以下注釋:
#
# cluster-enabled yes

# Every cluster node has a cluster configuration file. This file is not
# intended to be edited by hand. It is created and updated by Redis nodes.
# Every Redis Cluster node requires a different cluster configuration file.
# Make sure that instances running in the same system does not have
# overlapping cluster configuration file names.
# 每個(gè)集群節(jié)點(diǎn)都有一個(gè)集群配置文件。此文件不可手動(dòng)編輯。它有Redis節(jié)點(diǎn)創(chuàng)建和更新。每個(gè)Redis集群
# 節(jié)點(diǎn)都需要不同的集群配置文件。確保在同一系統(tǒng)中運(yùn)行的實(shí)例沒(méi)有重疊的集群配置文件名。
#
# cluster-config-file nodes-6379.conf

# Cluster node timeout is the amount of milliseconds a node must be unreachable 
# for it to be considered in failure state.
# Most other internal time limits are multiple of the node timeout.
# 集群節(jié)點(diǎn)無(wú)法訪問(wèn)時(shí)間毫秒數(shù)被視為故障狀態(tài)。
# 大多數(shù)情況下超時(shí)時(shí)間是內(nèi)部節(jié)點(diǎn)的倍數(shù)。
# 
# cluster-node-timeout 15000

# Cluster slaves are able to migrate to orphaned masters, that are masters
# that are left without working slaves. This improves the cluster ability
# to resist to failures as otherwise an orphaned master can't be failed over
# in case of failure if it has no working slaves.
# 集群的從機(jī)器能夠遷移到孤立的主機(jī),即使主機(jī)器沒(méi)有工作中的從機(jī)器。這提高了集群抵抗故障的能力,
# 因?yàn)楣铝⒌臋C(jī)器沒(méi)有自己可用的從機(jī)器,則發(fā)生故障時(shí)無(wú)法對(duì)其進(jìn)行故障轉(zhuǎn)移。
#
# Slaves migrate to orphaned masters only if there are still at least a
# given number of other working slaves for their old master. This number
# is the "migration barrier". A migration barrier of 1 means that a slave
# will migrate only if there is at least 1 other working slave for its master
# and so forth. It usually reflects the number of slaves you want for every
# master in your cluster.
# 只有當(dāng)舊主機(jī)還有一定數(shù)量的其他從機(jī)器時(shí),從機(jī)器才會(huì)遷移到孤立主機(jī)那里。這個(gè)數(shù)字就是"migration barrier"。
# 遷移屏障為1意味著只有當(dāng)主設(shè)備至少有一個(gè)其他從機(jī)器工作時(shí),從機(jī)器才會(huì)遷移,以此類推。它通常反應(yīng)集群中每個(gè)
# 節(jié)點(diǎn)所需要的從節(jié)點(diǎn)數(shù)量。
#
# Default is 1 (slaves migrate only if their masters remain with at least
# one slave). To disable migration just set it to a very large value.
# A value of 0 can be set but is useful only for debugging and dangerous
# in production.
# 默認(rèn)值為1(當(dāng)其主機(jī)器至少有一臺(tái)從機(jī)器時(shí),從機(jī)器才會(huì)遷移)。要禁用遷移,只需要將其設(shè)置為非常大的值。
# 可以設(shè)置成0,但該值僅對(duì)debug有用,并且生產(chǎn)中很危險(xiǎn)。
#
# cluster-migration-barrier 1

# In order to setup your cluster make sure to read the documentation
# available at http://redis.io web site.
# 要設(shè)置集群,請(qǐng)務(wù)必閱讀以下站點(diǎn)提供的文檔。
# http://redis.io

################################## SLOW LOG ###################################

# The Redis Slow Log is a system to log queries that exceeded a specified
# execution time. The execution time does not include the I/O operations
# like talking with the client, sending the reply and so forth,
# but just the time needed to actually execute the command (this is the only
# stage of command execution where the thread is blocked and can not serve
# other requests in the meantime).
# Redis慢日志系統(tǒng),用于記錄超過(guò)指定執(zhí)行時(shí)間的查詢。執(zhí)行時(shí)間不包括I/O操作,例如客戶端會(huì)話、發(fā)送回復(fù)等,
# 而只包含實(shí)際執(zhí)行命令所需要的時(shí)間(這是命令執(zhí)行的唯一階段,線程被阻塞,同時(shí)不同服務(wù)于其他請(qǐng)求)。
# 
# You can configure the slow log with two parameters: one tells Redis
# what is the execution time, in microseconds, to exceed in order for the
# command to get logged, and the other parameter is the length of the
# slow log. When a new command is logged the oldest one is removed from the
# queue of logged commands.
# 您可以使用兩個(gè)參數(shù)配置慢日志:一個(gè)參數(shù)告訴Redis為了記錄命令要超過(guò)的執(zhí)行時(shí)間微妙,另一個(gè)參數(shù)是慢
# 速日志的長(zhǎng)度。記錄新命令時(shí),將從記錄的命令隊(duì)列中刪除最舊的命令。

# The following time is expressed in microseconds, so 1000000 is equivalent
# to one second. Note that a negative number disables the slow log, while
# a value of zero forces the logging of every command.
# 以下時(shí)間單位為微妙,因此1000000相當(dāng)于1秒。請(qǐng)注意,負(fù)數(shù)將禁用慢日志,而0將強(qiáng)制記錄每個(gè)命令。

slowlog-log-slower-than 10000

# There is no limit to this length. Just be aware that it will consume memory.
# You can reclaim memory used by the slow log with SLOWLOG RESET.
# 這個(gè)長(zhǎng)度沒(méi)有限制。但它將消耗內(nèi)存。
# 您可以使用SLOWLOG RESET回收慢日志內(nèi)存。

slowlog-max-len 128

############################# Event notification ##############################

# Redis can notify Pub/Sub clients about events happening in the key space.
# This feature is documented at http://redis.io/topics/keyspace-events
# Redis可以將key空間中發(fā)生的事件通知客戶端(發(fā)布/訂閱)。
# 此功能詳細(xì):http://redis.io/topics/keyspace-events
# 
# For instance if keyspace events notification is enabled, and a client
# performs a DEL operation on key "foo" stored in the Database 0, two
# messages will be published via Pub/Sub:
# 例如:如果啟用了key空間事件通知,并且客戶端對(duì)數(shù)據(jù)庫(kù)0中存儲(chǔ)的key執(zhí)行了DEL操作,將通過(guò)pub/sub
# 發(fā)布兩條消息:
#
# PUBLISH __keyspace@0__:foo del
# PUBLISH __keyevent@0__:del foo
#
# It is possible to select the events that Redis will notify among a set
# of classes. Every class is identified by a single character:
# 可以在一組類中選擇Redis將通知的事件。每個(gè)類都由一個(gè)字符標(biāo)識(shí):
#
#  K     Keyspace events, published with __keyspace@<db>__ prefix.
#  E     Keyevent events, published with __keyevent@<db>__ prefix.
#  g     Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
#  $     String commands
#  l     List commands
#  s     Set commands
#  h     Hash commands
#  z     Sorted set commands
#  x     Expired events (events generated every time a key expires)
#  e     Evicted events (events generated when a key is evicted for maxmemory)
#  A     Alias for g$lshzxe, so that the "AKE" string means all the events.
#
#  The "notify-keyspace-events" takes as argument a string that is composed
#  by zero or multiple characters. The empty string means that notifications
#  are disabled at all.
# "notify-keyspace-events"將有0個(gè)或多個(gè)字符串作為參數(shù)。空字符串表示完全禁用通知。
#
#  Example: to enable list and generic events, from the point of view of the
#           event name, use:
#  例如:要啟用list和常規(guī)命令事件,從事件名稱的角度來(lái)看,請(qǐng)使用:
#
#  notify-keyspace-events Elg
#
#  Example 2: to get the stream of the expired keys subscribing to channel
#             name __keyevent@0__:expired use:
#  例子2:獲取訂閱通道名稱的過(guò)期key
#
#  notify-keyspace-events Ex
#
#  By default all notifications are disabled because most users don't need
#  this feature and the feature has some overhead. Note that if you don't
#  specify at least one of K or E, no events will be delivered.
#  默認(rèn)情況下所有通知都被禁用,因?yàn)榇蠖鄶?shù)用戶不需要此功能,和此功能帶來(lái)的一些開(kāi)銷。請(qǐng)注意,如果
#  沒(méi)有指定K或者E中的至少一個(gè),則不會(huì)傳遞任何事件。

notify-keyspace-events ""

############################### ADVANCED CONFIG ###############################

# Hashes are encoded using a memory efficient data structure when they have a
# small number of entries, and the biggest entry does not exceed a given
# threshold. These thresholds can be configured using the following directives.
# 當(dāng)散列有較少數(shù)據(jù)時(shí),且最大條目不超過(guò)給定的閾值時(shí),使用內(nèi)存高效的數(shù)據(jù)結(jié)構(gòu)進(jìn)行編碼??梢允褂靡韵屡渲眠@些閾值。

hash-max-ziplist-entries 512
hash-max-ziplist-value 64

# Similarly to hashes, small lists are also encoded in a special way in order
# to save a lot of space. The special representation is only used when
# you are under the following limits:
# 與散列類似,小列表也以特殊的方式編碼,來(lái)節(jié)省大量的空間。當(dāng)處于以下限制條件時(shí),才使用特殊限制:

list-max-ziplist-entries 512
list-max-ziplist-value 64

# Sets have a special encoding in just one case: when a set is composed
# of just strings that happens to be integers in radix 10 in the range
# of 64 bit signed integers.
# 在某種情況下,集合有一種特殊的編碼方式:
# The following configuration setting sets the limit in the size of the
# set in order to use this special memory saving encoding.
# 以下配置設(shè)置集合的大小限制,以便使用特殊的內(nèi)存節(jié)省編碼。
set-max-intset-entries 512

# Similarly to hashes and lists, sorted sets are also specially encoded in
# order to save a lot of space. This encoding is only used when the length and
# elements of a sorted set are below the following limits:
# 與散列和列表類似,sorted也經(jīng)過(guò)特殊的編碼節(jié)省大量的空間。此編碼僅在sorted長(zhǎng)度和元素低于以下限制時(shí)使用:

zset-max-ziplist-entries 128
zset-max-ziplist-value 64

# HyperLogLog sparse representation bytes limit. The limit includes the
# 16 bytes header. When an HyperLogLog using the sparse representation crosses
# this limit, it is converted into the dense representation.
#
# A value greater than 16000 is totally useless, since at that point the
# dense representation is more memory efficient.
# 
# The suggested value is ~ 3000 in order to have the benefits of
# the space efficient encoding without slowing down too much PFADD,
# which is O(N) with the sparse encoding. The value can be raised to
# ~ 10000 when CPU is not a concern, but space is, and the data set is
# composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
hll-sparse-max-bytes 3000

# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
# order to help rehashing the main Redis hash table (the one mapping top-level
# keys to values). The hash table implementation Redis uses (see dict.c)
# performs a lazy rehashing: the more operation you run into a hash table
# that is rehashing, the more rehashing "steps" are performed, so if the
# server is idle the rehashing is never complete and some more memory is used
# by the hash table.
# 
# The default is to use this millisecond 10 times every second in order to
# active rehashing the main dictionaries, freeing memory when possible.
#
# If unsure:
# use "activerehashing no" if you have hard latency requirements and it is
# not a good thing in your environment that Redis can reply form time to time
# to queries with 2 milliseconds delay.
#
# use "activerehashing yes" if you don't have such hard requirements but
# want to free memory asap when possible.
activerehashing yes

# The client output buffer limits can be used to force disconnection of clients
# that are not reading data from the server fast enough for some reason (a
# common reason is that a Pub/Sub client can't consume messages as fast as the
# publisher can produce them).
#
# The limit can be set differently for the three different classes of clients:
#
# normal -> normal clients
# slave  -> slave clients and MONITOR clients
# pubsub -> clients subscribed to at least one pubsub channel or pattern
#
# The syntax of every client-output-buffer-limit directive is the following:
#
# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
#
# A client is immediately disconnected once the hard limit is reached, or if
# the soft limit is reached and remains reached for the specified number of
# seconds (continuously).
# So for instance if the hard limit is 32 megabytes and the soft limit is
# 16 megabytes / 10 seconds, the client will get disconnected immediately
# if the size of the output buffers reach 32 megabytes, but will also get
# disconnected if the client reaches 16 megabytes and continuously overcomes
# the limit for 10 seconds.
#
# By default normal clients are not limited because they don't receive data
# without asking (in a push way), but just after a request, so only
# asynchronous clients may create a scenario where data is requested faster
# than it can read.
#
# Instead there is a default limit for pubsub and slave clients, since
# subscribers and slaves receive data in a push fashion.
#
# Both the hard or the soft limit can be disabled by setting them to zero.
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

# Redis calls an internal function to perform many background tasks, like
# closing connections of clients in timeout, purging expired keys that are
# never requested, and so forth.
#
# Not all tasks are performed with the same frequency, but Redis checks for
# tasks to perform accordingly to the specified "hz" value.
#
# By default "hz" is set to 10. Raising the value will use more CPU when
# Redis is idle, but at the same time will make Redis more responsive when
# there are many keys expiring at the same time, and timeouts may be
# handled with more precision.
#
# The range is between 1 and 500, however a value over 100 is usually not
# a good idea. Most users should use the default of 10 and raise this up to
# 100 only in environments where very low latency is required.
hz 10

# When a child rewrites the AOF file, if the following option is enabled
# the file will be fsync-ed every 32 MB of data generated. This is useful
# in order to commit the file to the disk more incrementally and avoid
# big latency spikes.
aof-rewrite-incremental-fsync yes

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容