redis.conf配置文件詳細講解(二)

4.      經常使用配置說明node

####GENERAL #####################################[l1] redis

 

# Bydefault Redis does not run as a daemon. Use 'yes' if you need it.數據庫

# Note that Redis will write a pid filein /var/run/redis.pid when daemonized.[l2] 安全

daemonize no服務器

 

#If you run Redis from upstart or systemd, Redis can interact with your網絡

# supervision tree. Options:[l3] app

#   supervised no      - no supervision interaction[l4] less

#   supervised upstart - signal upstartby putting Redis into SIGSTOP mode[l5] 異步

#   supervised systemd - signal systemdby writing READY=1 to $NOTIFY_SOCKET[l6] socket

#   supervised auto    - detect upstart or systemd method based on

#                        UPSTART_JOB orNOTIFY_SOCKET environment variables[l7] 

#Note: these supervision methods only signal "process is ready."[l8] 

#       They do not enable continuous livenesspings back to your supervisor.[l9] 

supervised no

 

#If a pid file is specified, Redis writes it where specified at startup

# and removes it at exit.[l10] 

#

# Whenthe server runs non daemonized, no pid file is created if none is

# specified in the configuration. Whenthe server is daemonized, the pid file

# is used even if not specified,defaulting to "/var/run/redis.pid".[l11] 

#

#Creating a pid file is best effort: if Redis is not able to create it

# nothing bad happens, the server willstart and run normally.[l12] 

pidfile /var/run/redis_6379.pid

 

# Specifythe server verbosity level.[l13] 

# Thiscan be one of:

# debug (a lot of information, useful fordevelopment/testing)

# verbose (many rarely useful info, butnot a mess like the debug level)

# notice (moderately verbose, what youwant in production probably)

# warning (only very important / criticalmessages are logged)[l14] 

loglevel notice

 

# Specifythe 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, logswill be sent to /dev/null[l15] 

logfile ""

 

# Toenable logging to the system logger, just set 'syslog-enabled' to yes,

# and optionally update the other syslogparameters to suit your needs.

# syslog-enabled no[l16] 

 

# Specifythe syslog identity.[l17] 

# syslog-ident redis

 

# Specifythe syslog facility. Must be USER or between LOCAL0-LOCAL7.[l18] 

# syslog-facility local0

 

# Setthe number of databases. The default database is DB 0, you can select

# a different one on a per-connectionbasis using SELECT <dbid> where

# dbid is a number between 0 and'databases'-1[l19] 

databases 16

5.      快照設置說明

###### SNAPSHOTTING[l20]   ################################

#

#Save the DB on disk:[l21] 

#

#   save <seconds> <changes>[l22] 

#

#   Will save the DB if both the given numberof seconds and the given

#  number of write operations against the DB occurred.[l23] 

#

#   In the example below the behaviour will beto save:

#  after 900 sec (15 min) if at least 1 key changed

#  after 300 sec (5 min) if at least 10 keys changed

#  after 60 sec if at least 10000 keys changed[l24] 

#

#   Note: you can disable saving completely bycommenting out all "save" lines.[l25] 

#

#   It is also possible to remove all thepreviously configured save

#  points by adding a save directive with a single empty string argument

#  like in the following example:

#

#  save ""[l26] 

 

save 900 1

save 300 10

save 60 10000

 

# Bydefault Redis will stop accepting writes if RDB snapshots are enabled

# (at least one save point) and thelatest background save failed.

# This will make the user aware (in ahard way) that data is not persisting

# on disk properly, otherwise chances arethat no one will notice and some

# disaster will happen.[l27] 

#

# Ifthe background saving process will start working again Redis will

# automatically allow writes again.[l28] 

#

# Howeverif you have setup your proper monitoring of the Redis server

# and persistence, you may want todisable this feature so that Redis will

# continue to work as usual even if thereare problems with disk,

# permissions, and so forth.[l29] 

stop-writes-on-bgsave-error yes

 

#Compress string objects using LZF when dump .rdb databases?

# For default that's set to 'yes' as it'salmost always a win.

# If you want to save some CPU in thesaving child set it to 'no' but

# the dataset will likely be bigger ifyou have compressible values or keys.[l30] 

rdbcompression yes

 

#Since version 5 of RDB a CRC64 checksum is placed at the end of the file.

# This makes the format more resistant tocorruption but there is a performance

# hit to pay (around 10%) when saving andloading RDB files, so you can disable it

# for maximum performances.[l31] 

#

#RDB files created with checksum disabled have a checksum of zero that will

# tell the loading code to skip thecheck.[l32] 

rdbchecksum yes

 

# Thefilename where to dump the DB[l33] 

dbfilename dump.rdb

 

# Theworking directory.[l34] 

#

# TheDB will be written inside this directory, with the filename specified

# above using the 'dbfilename'configuration directive.[l35] 

#

# TheAppend Only File will also be created inside this directory.[l36] 

#

# Notethat you must specify a directory here, not a file name.[l37] 

dir ./

6.      主從複製設置說明

######## REPLICATION[l38] #################################

 

# Master-Slavereplication. Use slaveof to make a Redis instance a copy of

# another Redis server. A few things tounderstand ASAP about Redis replication.[l39] 

#

# 1)Redis replication is asynchronous, but you can configure a master to

#   stop accepting writes if it appears to be not connected with at least

#   a given number of slaves.[l40] 

#2) Redis slaves are able to perform a partial resynchronization with the

#   master if the replication link is lost for a relatively small amount of

#   time. You may want to configure the replication backlog size (see thenext

#   sections of this file) with a sensible value depending on your needs.[l41] 

#3) Replication is automatic and does not need user intervention. After a

#   network partition slaves automatically try to reconnect to masters

#   and resynchronize with them.[l42] 

#

#slaveof <masterip> <masterport>[l43] 

 

#If the master is password protected (using the "requirepass"configuration

# directive below) it is possible to tellthe slave to authenticate before

# starting the replicationsynchronization process, otherwise the master will

# refuse the slave request.[l44] 

#

# masterauth <master-password>

 

# Whena slave loses its connection with the master, or when the replication

# is still in progress, the slave can actin two different ways:[l45] 

#

# 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.[l46] 

#

#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 ofcommands

#   but to INFO and SLAVEOF.[l47] 

#

slave-serve-stale-data yes

 

# Youcan configure a slave instance to accept writes or not. Writing against

# a slave instance may be useful to storesome ephemeral data (because data

# written on a slave will be easilydeleted after resync with the master) but

# may also cause problems if clients arewriting to it because of a

# misconfiguration.[l48] 

#

#Since Redis 2.6 by default slaves are read-only[l49] .

#

# Note:read only slaves are not designed to be exposed to untrusted clients

# on the internet. It's just a protectionlayer against misuse of the instance.

# Still a read only slave exports bydefault all the administrative commands

# such as CONFIG, DEBUG, and so forth. Toa limited extent you can improve

# security of read only slaves using'rename-command' to shadow all the

# administrative / dangerous commands.[l50] 

slave-read-only yes

 

#Replication SYNC strategy: disk or socket.[l51] 

#

# -------------------------------------------------------

#WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY[l52] 

# -------------------------------------------------------

#

# Newslaves and reconnecting slaves that are not able to continue the replication

# process just receiving differences,need to do what is called a "full

# synchronization". An RDB file istransmitted from the master to the slaves.

# The transmission can happen in twodifferent ways:[l53] 

#

# 1)Disk-backed: The Redis master creates a new process that writes the RDB

#                 file on disk. Later the fileis transferred by the parent

#                 process to the slavesincrementally.[l54] 

#2) Diskless: The Redis master creates a new process that directly writes the

#             RDB file to slave sockets,without touching the disk at all.[l55] 

#

# Withdisk-backed replication, while the RDB file is generated, more slaves

# can be queued and served with the RDBfile as soon as the current child producing

# the RDB file finishes its work. Withdiskless replication instead once

# the transfer starts, new slavesarriving will be queued and a new transfer

# will start when the current oneterminates.[l56] 

#

#When diskless replication is used, the master waits a configurable amount of

# time (in seconds) before starting thetransfer in the hope that multiple slaves

# will arrive and the transfer can beparallelized.[l57] 

#

# Withslow disks and fast (large bandwidth) networks, diskless replication

# works better.[l58] 

repl-diskless-sync no

 

# Whendiskless replication is enabled, it is possible to configure the delay

# the server waits in order to spawn thechild that transfers the RDB via socket

# to the slaves[l59] .

#

# Thisis important since once the transfer starts, it is not possible to serve

# new slaves arriving, that will bequeued for the next RDB transfer, so the server

# waits a delay in order to let moreslaves arrive.[l60] 

#

# Thedelay is specified in seconds, and by default is 5 seconds. To disable

# it entirely just set it to 0 secondsand the transfer will start ASAP.[l61] 

repl-diskless-sync-delay 5

 

# Slavessend PINGs to server in a predefined interval. It's possible to change

# this interval with the repl_ping_slave_periodoption. The default value is 10

# seconds.[l62] 

#

# repl-ping-slave-period 10

 

# Thefollowing option sets the replication timeout for:[l63] 

#

# 1)Bulk transfer I/O during SYNC, from the point of view of slave.

# 2) Master timeout from the point ofview of slaves (data, pings).

# 3) Slave timeout from the point of viewof masters (REPLCONF ACK pings).[l64] 

#

#It is important to make sure that this value is greater than the value

# specified for repl-ping-slave-periodotherwise a timeout will be detected

# every time there is low traffic betweenthe master and the slave.[l65] 

#

# repl-timeout 60

 

# DisableTCP_NODELAY on the slave socket after SYNC?[l66] 

#

#If you select "yes" Redis will use a smaller number of TCP packetsand

# 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 defaultconfiguration.[l67] 

#

# Ifyou select "no" the delay for data to appear on the slave side will

# be reduced but more bandwidth will beused for replication.[l68] 

#

#By default we optimize for low latency, but in very high traffic conditions

# or when the master and slaves are manyhops away, turning this to "yes" may

# be a good idea.[l69] 

repl-disable-tcp-nodelay no

 

#Set the replication backlog size. The backlog is a buffer that accumulates

# slave data when slaves are disconnectedfor some time, so that when a slave

# wants to reconnect again, often a fullresync is not needed, but a partial

# resync is enough, just passing theportion of data the slave missed while

# disconnected.[l70] 

#

# Thebigger the replication backlog, the longer the time the slave can be

# disconnected and later be able toperform a partial resynchronization.[l71] 

#

#The backlog is only allocated once there is at least a slave connected[l72] .

#

# repl-backlog-size 1mb

 

# Aftera master has no longer connected slaves for some time, the backlog

# will be freed. The following optionconfigures the amount of seconds that

# need to elapse, starting from the timethe last slave disconnected, for

# the backlog buffer to be freed.[l73] 

#

# Avalue of 0 means to never release the backlog.[l74] 

#

# repl-backlog-ttl 3600

 

# Theslave priority is an integer number published by Redis in the INFO output.

# It is used by Redis Sentinel in orderto select a slave to promote into a

# master if the master is no longerworking correctly.[l75] 

#

# Aslave with a low priority number is considered better for promotion, so

# for instance if there are three slaveswith priority 10, 100, 25 Sentinel will

# pick the one with priority 10, that isthe lowest.[l76] 

#

# Howevera special priority of 0 marks the slave as not able to perform the

# role of master, so a slave withpriority of 0 will never be selected by

# Redis Sentinel for promotion.[l77] 

#

#By default the priority is 100.[l78] 

slave-priority 100

 

# Itis possible for a master to stop accepting writes if there are less than

# N slaves connected, having a lag lessor equal than M seconds.[l79] 

#

# TheN slaves need to be in "online" state.[l80] 

#

# Thelag in seconds, that must be <= the specified value, is calculated from

# the last ping received from the slave,that is usually sent every second.[l81] 

#

#This option does not GUARANTEE that N replicas will accept the write, but

# will limit the window of exposure forlost writes in case not enough slaves

# are available, to the specified numberof seconds.[l82] 

#

# Forexample to require at least 3 slaves with a lag <= 10 seconds use:[l83] 

#

# min-slaves-to-write 3

# min-slaves-max-lag 10

#

# Settingone or the other to 0 disables the feature.[l84] 

#

#By default min-slaves-to-write is set to 0 (feature disabled) and

# min-slaves-max-lag is set to 10.[l85] 

 

# ARedis master is able to list the address and port of the attached

# slaves in different ways. For examplethe "INFO replication" section

# offers this information, which is used,among other tools, by

# Redis Sentinel in order to discoverslave instances.

# Another place where this info isavailable is in the output of the

# "ROLE" command of a masteer.[l86] 

#

#The listed IP and address normally reported by a slave is obtained

# in the following way:[l87] 

#

 IP:The address is auto detected by checking the peer address

#  of the socket used by the slave to connect with the master.[l88] 

#

#   Port: The port is communicated by theslave during the replication

#  handshake, and is normally the port that the slave is using to

#  list for connections.[l89] 

#

#However when port forwarding or Network Address Translation (NAT) is

# used, the slave may be actuallyreachable via different IP and port

# pairs. The following two options can beused by a slave in order to

# report to its master a specific set ofIP and port, so that both INFO

# and ROLE will report those values.[l90] 

#

# Thereis no need to use both the options if you need to override just

# the port or the IP address.[l91] 

#

# slave-announce-ip 5.5.5.5

# slave-announce-port 1234


 [l1]經常使用配置說明

 [l2]默認狀況下Redis不做爲守護程序運行。 若是須要,使用「yes」。 注意,Redis在守護進程時會在/var/run/redis.pid中寫一個pid文件。

 [l3]若是從upstartsystemd運行RedisRedis能夠與您的管理樹進行交互。選項:

 [l4]無管理的互動

 [l5]經過將Redis置於SIGSTOP模式來使信號Upstart

 [l6]經過將READY = 1寫入$ NOTIFY_SOCKET信號systemd

 [l7]基於UPSTART_JOBNOTIFY_SOCKET環境變量檢測upstartsystemd方法

 [l8]注意:這些管理方法只是信號「過程就緒」。

 [l9]他們不能連續的liveness ping回你的管理。

 [l10]若是指定了pid文件,Redis會啓動時在指定的位置寫入該文件,並在退出時將其刪除。

 [l11]當服務器運行非守護進程時,若是在配置中未指定任何pid文件,則不會建立pid文件。當服務器進行守護進程時,即便未指定,也使用pid文件,默認爲「/var/run/redis.pid」。

 [l12]建立pid文件是最好的努力:若是Redis沒法建立它沒有什麼很差發生,服務器將啓動並正常運行。

 [l13]定義日誌級別

 [l14]這能夠是如下之一:

debug(不少信息,對開發/測試有用)
verbose(不多有用的信息,但不像調試級別的混亂)
notice(適度冗長,適用於生成環境)

warning(僅記錄很是重要/關鍵的消息)

 [l15]指定日誌文件名。 此外,空字符串可用於強制Redis登陸標準輸出。 請注意,若是您使用標準輸出進行日誌記錄,但使用守護進程,則日誌將發送到/ dev / null

 [l16]要啓用日誌記錄到系統記錄器,只需將「syslog-enabled」設置爲yes,並可選擇更新其餘syslog參數以知足您的須要。 syslog啓用no

 [l17]指定syslog標識。

 [l18]指定syslog設施。 必須是USERLOCAL0-LOCAL7之間。

 [l19]設置數據庫的數量。 默認數據庫是DB 0,可使用SELECT<dbid>在每一個鏈接的基礎上選擇不一樣的數據庫,其中dbid是介於0'databases'-1之間的數字

 [l20]快照

 [l21]將數據存入硬盤

 [l22]格式:save <間隔時間(秒)> <寫入次數>

 [l23]根據給定的時間間隔和寫入次數將數據保存到磁盤

 [l24]下面的例子的意思是:
900 秒內若是至少有 1 個 key 的值變化,則保存
300 秒內若是至少有 10 個 key 的值變化,則保存
60 秒內若是至少有 10000 個 key 的值變化,則保存

 [l25]注意:你能夠註釋掉全部的save行來停用保存功能。

 [l26]也能夠經過添加具備單個空字符串參數的save指令來刪除全部之前配置的保存點,以下例所示:save "" [l26]

 [l27]默認狀況下,若是啓用了RDB快照(至少一個保存點)而且最近的後臺保存失敗,Redis將中止接受寫入。這將使用戶意識到(以硬的方式)數據不是正確地持久存儲在磁盤上,不然多是沒有人會注意到災難的發生。

 [l28]若是後臺報錯進程從新啓動了,redis也將自動的容許寫操做

 [l29]可是,若是你有設置您的Redis的服務器和持久性的適當監督,你可能要禁用此功能,Redis的將繼續照常即便有磁盤,權限問題的工做,等等。

 [l30]轉儲.rdb數據庫時使用LZF壓縮字符串對象? 對於被設置爲「是」。若是你想節省一些CPU在節能孩子將其設置爲「無」,但該數據集可能會更大,若是你有可壓縮數值或按鍵。

 [l31]RDB的版本5開始,在文件的末尾會進行CRC64校驗。 這使得格式更加嚴謹,可是在保存和加載RDB文件時有一個性能損失(大約10%),因此你能夠禁用它的最大性能。

 [l32]禁用和建立的RDB文件的校驗,這將告訴加載代碼跳過檢查

 [l33]轉儲數據庫的文件名

 [l34]工做目錄

 [l35]DB將使用'dbfilename'配置指令在此目錄中寫入上面指定的文件名。

 [l36]追加文件也將在此目錄中建立。

 [l37]請注意,您必須在此指定目錄,而不是文件名。

 [l38]主從複製

 [l39]主從複製。 使用slaveof使Redis實例成爲另外一個Redis服務器的副本。 關於Redis複製的幾個事情。

 [l40]1Redis複製是異步的,可是若是它看起來沒有與指定的從設備鏈接,您能夠將主機配置爲中止接受寫入。

 [l41]2)若是複製鏈路丟失相對較少的時間,Redis從設備可以與主設備執行部分從新同步。您可能須要根據您的須要使用合理的值配置複製積壓大小(請參閱此文件的下一部分)。

 [l42]3)複製是自動的,不須要用戶干預。 網絡分區後,自動嘗試從新鏈接到主控器並與它們從新同

 [l43]注意這個只須要在slave上配置,

配置格式是:slaveof IP  主端口

 [l44]若是主密碼保護(使用下面的「requirepass」配置指令),能夠在開始複製同步過程以前告訴從設備進行認證,不然主設備將拒絕從設備請求。

 [l45]當從站失去與主站的鏈接時,或者當複製仍在進行中時,從站可能有兩種表現:

 [l46]1)若是slave-serve-stale-data設置爲「yes」(默認值),則從設備仍將回復客戶端請求,可能使用過時數據,或者若是這是第一個同步,則數據集可能只爲空

 [l47]2)若是slave-serve-stale-data設置爲「no」,從設備將回復錯誤「SYNC with master in progress」給除INFOSLAVEOF意外全部類型的命令。

 [l48]您能夠配置從實例接受寫入或不接受寫入。對從實例進行寫操做對於存儲一些臨時數據多是有用的(由於寫在從屬設備上的數據將在與主設備從新同步後很容易被刪除),可是若是客戶端由於錯誤配置而寫入它,也會致使問題

 [l49]Redis 2.6默認的從機是隻讀的

 [l50]注意:只讀從站不設計爲暴露給互聯網上的不受信任的客戶端。 它只是一個防止實例濫用的保護層。只讀slave默認狀況下輸出全部管理命令,如CONFIGDEBUG等等。在有限的程度上,您可使用「rename-command」來提升只讀從設備的安全性,以隱藏全部管理/危險命令

 [l51]複製SYNC策略:磁盤或套接字。

 [l52]警告:不可靠的複製是當前的設置

 [l53]新的從和從新鏈接的從,不能繼續複製過程只是接收差別,須要作的就是所謂的「徹底同步」。 RDB文件從主機傳輸到從機。傳輸能夠以兩種不一樣的方式:

 [l54]1)磁盤支持:Redis主機建立一個新的進程,將RDB文件寫入磁盤。稍後,文件由父進程以增量方式傳送到從屬。

 [l55]2)無盤:Redis主機建立一個新的進程,直接將RDB文件寫入從屬插槽,而不觸及磁盤。

 [l56]使用磁盤支持的複製,在生成RDB文件時,只要生成RDB文件的當前子項完成其工做,就能夠排隊更多的從屬並使用RDB文件提供。使用無盤複製,一旦傳輸開始,新從站到達將排隊,而且噹噹前終止時新的傳輸將開始

 [l57]當使用無盤複製時,主機在開始傳輸以前等待可配置的時間量(以秒爲單位),以防止多個從機到達而且傳輸能夠並行化。

 [l58]使用慢磁盤和快速(大帶寬)網絡,無盤複製的效果更好。

 [l59]當啓用無盤複製時,能夠配置服務器等待的延遲,以便生成經過套接字將RDB傳輸到從屬的子節點

 [l60]這是很重要的,由於一旦傳輸開始,不可能服務新的從設備到達,將爲下一個RDB傳輸排隊,所以服務器等待延遲,以便讓更多的從設備到達。

 [l61]延遲以秒爲單位指定,默認值爲5秒。 要徹底禁用它只是設置爲0秒,傳輸將盡快啓動

 [l62]從設備以預約義的時間間隔向服務器發送PING可使用repl_ping_slave_period選項更改此時間間隔。默認值爲10

 [l63]如下選項設置複製超時:

 [l64]1SYNC期間的批量傳輸I / O,從從機的角度看。
2)從從機(數據,ping)的角度看主機超時。
3)從主機(REPLCONF ACK ping)的角度看從機超時

 [l65]重要的是要確保此值大於爲repl-ping-slave-period指定的值,不然每次主站和從站之間的流量低時都會檢測到超時。

 [l66]SYNC以後在從站插槽上禁用TCP_NODELAY

 [l67]若是選擇「是」,Redis將使用較少數量的TCP數據包和較少的帶寬將數據發送到從站。 可是這能夠增長數據在從端面上出現的延遲,對於Linux內核,使用默認配置能夠延遲40毫秒

 [l68]若是選擇「否」,數據在從機端顯示的延遲將會減小,但更多的帶寬將用於複製。

 [l69]默認狀況下,咱們針對低延遲進行優化,但在很是高的流量條件下或當主設備和從設備有許多跳時,將其轉換爲「是」多是一個好主意。

 [l70]設置複製容量大小。 容量是一個緩衝器,當從機斷開一段時間時積累從機數據,以便當從機想要再次從新鏈接時,一般不須要徹底再同步,可是部分再同步就足夠了,只是將在斷開鏈接時的數據傳遞給從機

 [l71]複製容量越大,從設備能夠斷開鏈接的時間就越長,之後就能夠執行部分從新同步。

 [l72]只有至少有一個從站鏈接時才分配容量大小

 [l73]在主機已經再也不鏈接從機一段時間後,容納將被釋放。 如下選項配置從最後一個從服務器斷開的時間開始,須要通過的秒數,以使待處理緩衝區被釋放

 [l74]值爲0表示永不釋放backlog

 [l75]從屬優先級是由RedisINFO輸出中發佈的整數。 它由RedisSentinel使用,以便選擇從屬設備,若是主設備再也不正常工做,則升級爲主設備

 [l76]具備低優先級編號的從設備被認爲更好的提高,所以若是存在具備優先級10,100,25的三個從設備,則哨兵將選擇具備優先級10,即最低的那個。

 [l77]然而,0的特殊優先級標誌着從設備不能執行主設備的角色,所以優先級爲0的從設備將不會被Redis Sentinel選擇用於升級。

 [l78]默認優先級爲100

 [l79]若是存在少於鏈接的從設備,具備小於或等於M秒的滯後,則主設備能夠中止接受寫入。

 [l80]N個從站須要處於「在線」狀態。

 [l81]以秒爲單位的滯後,必須小於指定值,根據從從設備接收的最後一次ping計算,一般每秒發送一次。

 [l82]此選項不保證N個副本將接受寫入,但會在沒有足夠從屬設備可用的狀況下將丟失寫入的曝光窗口限制爲指定的秒數。

 [l83]例如,要求至少3個滯後<= 10秒的從站使用:

 [l84]將一個或另外一個設置爲0將禁用該功能。

 [l85]默認狀況下,min-slave-to-write設置爲0(禁用功能),min-slaves-max-lag設置爲10

 [l86]Redis主機可以以不一樣的方式列出所鏈接從機的地址和端口。例如,「INFO複製」部分提供此信息,除了其餘工具以外,Redis Sentinel還使用該信息來發現從屬實例。此信息可用的另外一個地方是在masterser的「ROLE」命令的輸出中

 [l87]經過從設備正常報告的列出的IP和地址經過如下方式得到:

 [l88]IP:經過檢查從設備與主設備鏈接使用的套接字的對等體地址自動檢測地址。

 [l89]端口:端口在複製握手期間由從設備通訊,而且一般是從設備正用於列出鏈接的端口。

 [l90]然而,當使用端口轉發或網絡地址轉換(NAT)時,從屬實際上能夠經過不一樣的IP和端口對來到達。如下兩個選項能夠由從設備使用,以便向其主設備報告一組特定的IP和端口,以便INFOROLE將報告這些值

 [l91]若是您須要僅覆蓋端口或IP地址,則不須要使用這兩個選項。