redis.conf 翻譯與配置(二)【redis6.0.6】

      網友投稿 867 2025-03-31

      學習Redis的途中,碰上了Redis.conf,突發奇想,想著來進行一波翻譯輸出。


      源碼之前,了無秘密。

      文章目錄

      快照

      原文

      譯文

      主從復制

      原文

      譯文

      追蹤鍵

      原文

      譯文

      快照

      原文

      ################################ SNAPSHOTTING ################################ # # Save the DB on disk: # # save # # Will save the DB if both the given number of seconds and the given # number of write operations against the DB occurred. # # In the example below the behaviour will be to 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 # # Note: you can disable saving completely by commenting out all "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: # # 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. # # If the background saving process will start working again Redis will # automatically allow writes again. # # 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. 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. 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 files created with checksum disabled have a checksum of zero that will # tell the loading code to skip the check. rdbchecksum yes # The filename where to dump the DB dbfilename dump.rdb # Remove RDB files used by replication in instances without persistence # enabled. By default this option is disabled, however there are environments # where for regulations or other security concerns, RDB files persisted on # disk by masters in order to feed replicas, or stored on disk by replicas # in order to load them for the initial synchronization, should be deleted # ASAP. Note that this option ONLY WORKS in instances that have both AOF # and RDB persistence disabled, otherwise is completely ignored. # # An alternative (and sometimes better) way to obtain the same effect is # to use diskless replication on both master and replicas instances. However # in the case of replicas, diskless is not always an option. rdb-del-sync-files no # The working directory. # # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # # The Append Only File will also be created inside this directory. # # Note that you must specify a directory here, not a file name. dir ./

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      43

      44

      45

      46

      47

      48

      49

      50

      51

      52

      53

      54

      55

      56

      57

      58

      59

      60

      61

      62

      63

      64

      65

      66

      67

      68

      69

      70

      71

      72

      73

      74

      75

      76

      77

      78

      79

      80

      81

      將數據保存在磁盤上:save

      如果在給定的時間內發生了給定次數的寫操作,則將數據寫入磁盤。

      示例:

      save 900 1 //900秒內至少有一條數據寫入 save 300 10 //300秒內至少有10條數據寫入 save 60 10000 //60秒內至少有10000條數據寫入

      1

      2

      3

      注意:你可以通過注釋掉所有“保存”行來完全禁用保存。

      如果出現一次寫入磁盤操作失敗,redis將停止接收所有寫操作,以此來讓用戶知道數據不能正常的持久化到磁盤。

      如果后臺保存進程又活了,Redis將自動再次允許寫入。

      如果你安裝了可靠的監控,你可能不希望redis繼續保持這個功能了,那就改成 ‘no’ 就好了。

      將字符串轉儲至.rdb數據庫的字符串壓縮算法是LZF算法?

      默認情況下設置為yes,因為大部分情況下這樣是有優勢的。

      如果你想保存一些CPU,將它設置為’no’,但是如果你有可壓縮的值或鍵,數據集可能會更大。

      從第五代RDB版本開始,文件末尾添加了一個CRC64 校驗和。這提高了該模式的健壯性,但是在保存和加載RDB文件時,會有大約10%的性能損失,所以您可以禁用它以獲得最大的性能。

      禁用校驗和的RDB文件的校驗和為零,這將告訴加載代碼跳過檢查。

      刪除復制在實例中使用的RDB文件,但不啟用持久性。默認情況下,這個選項是禁用的,但是,在一些環境中,由于規則或其他安全考慮,應該盡快刪除主服務器保存在磁盤上以提供副本的RDB文件,或通過副本存儲在磁盤上以加載它們進行初始同步。注意,此選項僅在AOF和RDB持久性都禁用的情況下有效,否則將完全忽略。

      還有一種替代方法,相同效果(有時更好),是在主實例和副本實例上使用無磁盤復制。然而,對于副本,無磁盤并不總是可選的。

      工作目錄。

      DB將寫入到這個目錄中,使用上面使用’dbfilename’配置指令指定的文件名。

      “僅追加”文件也將在此目錄中創建。

      注意,這里必須指定目錄,而不是文件名。

      主從復制

      原文

      ################################# REPLICATION ################################# # Master-Replica replication. Use replicaof to make a Redis instance a copy of # another Redis server. A few things to understand ASAP about Redis replication. # # +------------------+ +---------------+ # | Master | ---> | Replica | # | (receive writes) | | (exact copy) | # +------------------+ +---------------+ # # 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 replicas. # 2) Redis replicas 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 the next # sections of this file) with a sensible value depending on your needs. # 3) Replication is automatic and does not need user intervention. After a # network partition replicas automatically try to reconnect to masters # and resynchronize with them. # # replicaof # If the master is password protected (using the "requirepass" configuration # directive below) it is possible to tell the replica to authenticate before # starting the replication synchronization process, otherwise the master will # refuse the replica request. # # masterauth # # However this is not enough if you are using Redis ACLs (for Redis version # 6 or greater), and the default user is not capable of running the PSYNC # command and/or other commands needed for replication. In this case it's # better to configure a special user to use with replication, and specify the # masteruser configuration as such: # # masteruser # # When masteruser is specified, the replica will authenticate against its # master using the new AUTH form: AUTH . # When a replica loses its connection with the master, or when the replication # is still in progress, the replica can act in two different ways: # # 1) if replica-serve-stale-data is set to 'yes' (the default) the replica 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. # # 2) if replica-serve-stale-data is set to 'no' the replica will reply with # an error "SYNC with master in progress" to all the kind of commands # but to INFO, replicaOF, AUTH, PING, SHUTDOWN, REPLCONF, ROLE, CONFIG, # SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, # COMMAND, POST, HOST: and LATENCY. # replica-serve-stale-data yes # You can configure a replica instance to accept writes or not. Writing against # a replica instance may be useful to store some ephemeral data (because data # written on a replica will be easily deleted after resync with the master) but # may also cause problems if clients are writing to it because of a # misconfiguration. # # Since Redis 2.6 by default replicas are read-only. # # Note: read only replicas 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 replica 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 replicas using 'rename-command' to shadow all the # administrative / dangerous commands. replica-read-only yes # Replication SYNC strategy: disk or socket. # # New replicas and reconnecting replicas that are not able to continue the # replication process just receiving differences, need to do what is called a # "full synchronization". An RDB file is transmitted from the master to the # replicas. # # The transmission can happen in two different ways: # # 1) Disk-backed: The Redis master creates a new process that writes the RDB # file on disk. Later the file is transferred by the parent # process to the replicas incrementally. # 2) Diskless: The Redis master creates a new process that directly writes the # RDB file to replica sockets, without touching the disk at all. # # With disk-backed replication, while the RDB file is generated, more replicas # can be queued and served with the RDB file as soon as the current child # producing the RDB file finishes its work. With diskless replication instead # once the transfer starts, new replicas arriving will be queued and a new # transfer will start when the current one terminates. # # When diskless replication is used, the master waits a configurable amount of # time (in seconds) before starting the transfer in the hope that multiple # replicas will arrive and the transfer can be parallelized. # # With slow disks and fast (large bandwidth) networks, diskless replication # works better. repl-diskless-sync no # When diskless replication is enabled, it is possible to configure the delay # the server waits in order to spawn the child that transfers the RDB via socket # to the replicas. # # This is important since once the transfer starts, it is not possible to serve # new replicas arriving, that will be queued for the next RDB transfer, so the # server waits a delay in order to let more replicas arrive. # # The delay is specified in seconds, and by default is 5 seconds. To disable # it entirely just set it to 0 seconds and the transfer will start ASAP. repl-diskless-sync-delay 5 # ----------------------------------------------------------------------------- # WARNING: RDB diskless load is experimental. Since in this setup the replica # does not immediately store an RDB on disk, it may cause data loss during # failovers. RDB diskless load + Redis modules not handling I/O reads may also # cause Redis to abort in case of I/O errors during the initial synchronization # stage with the master. Use only if your do what you are doing. # ----------------------------------------------------------------------------- # # Replica can load the RDB it reads from the replication link directly from the # socket, or store the RDB to a file and read that file after it was completely # recived from the master. # # In many cases the disk is slower than the network, and storing and loading # the RDB file may increase replication time (and even increase the master's # Copy on Write memory and salve buffers). # However, parsing the RDB file directly from the socket may mean that we have # to flush the contents of the current database before the full rdb was # received. For this reason we have the following options: # # "disabled" - Don't use diskless load (store the rdb file to the disk first) # "on-empty-db" - Use diskless load only when it is completely safe. # "swapdb" - Keep a copy of the current db contents in RAM while parsing # the data directly from the socket. note that this requires # sufficient memory, if you don't have it, you risk an OOM kill. repl-diskless-load disabled # Replicas send PINGs to server in a predefined interval. It's possible to # change this interval with the repl_ping_replica_period option. The default # value is 10 seconds. # # repl-ping-replica-period 10 # The following option sets the replication timeout for: # # 1) Bulk transfer I/O during SYNC, from the point of view of replica. # 2) Master timeout from the point of view of replicas (data, pings). # 3) Replica 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-replica-period otherwise a timeout will be detected # every time there is low traffic between the master and the replica. # # repl-timeout 60 # Disable TCP_NODELAY on the replica socket after SYNC? # # If you select "yes" Redis will use a smaller number of TCP packets and # less bandwidth to send data to replicas. But this can add a delay for # the data to appear on the replica side, up to 40 milliseconds with # Linux kernels using a default configuration. # # If you select "no" the delay for data to appear on the replica side will # be reduced but more bandwidth will be used for replication. # # By default we optimize for low latency, but in very high traffic conditions # or when the master and replicas are many hops away, turning this to "yes" may # be a good idea. repl-disable-tcp-nodelay no # Set the replication backlog size. The backlog is a buffer that accumulates # replica data when replicas are disconnected for some time, so that when a # replica wants to reconnect again, often a full resync is not needed, but a # partial resync is enough, just passing the portion of data the replica # missed while disconnected. # # The bigger the replication backlog, the longer the time the replica can be # disconnected and later be able to perform a partial resynchronization. # # The backlog is only allocated once there is at least a replica connected. # # repl-backlog-size 1mb # After a master has no longer connected replicas 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 replica disconnected, for # the backlog buffer to be freed. # # Note that replicas never free the backlog for timeout, since they may be # promoted to masters later, and should be able to correctly "partially # resynchronize" with the replicas: hence they should always accumulate backlog. # # A value of 0 means to never release the backlog. # # repl-backlog-ttl 3600 # The replica priority is an integer number published by Redis in the INFO # output. It is used by Redis Sentinel in order to select a replica to promote # into a master if the master is no longer working correctly. # # A replica with a low priority number is considered better for promotion, so # for instance if there are three replicas with priority 10, 100, 25 Sentinel # will pick the one with priority 10, that is the lowest. # # However a special priority of 0 marks the replica as not able to perform the # role of master, so a replica with priority of 0 will never be selected by # Redis Sentinel for promotion. # # By default the priority is 100. replica-priority 100 # It is possible for a master to stop accepting writes if there are less than # N replicas connected, having a lag less or equal than M seconds. # # The N replicas need to be in "online" state. # # The lag in seconds, that must be <= the specified value, is calculated from # the last ping received from the replica, that is usually sent every second. # # This option does not GUARANTEE that N replicas will accept the write, but # will limit the window of exposure for lost writes in case not enough replicas # are available, to the specified number of seconds. # # For example to require at least 3 replicas with a lag <= 10 seconds use: # # min-replicas-to-write 3 # min-replicas-max-lag 10 # # Setting one or the other to 0 disables the feature. # # By default min-replicas-to-write is set to 0 (feature disabled) and # min-replicas-max-lag is set to 10. # A Redis master is able to list the address and port of the attached # replicas in different ways. For example the "INFO replication" section # offers this information, which is used, among other tools, by # Redis Sentinel in order to discover replica instances. # Another place where this info is available is in the output of the # "ROLE" command of a master. # # The listed IP and address normally reported by a replica is obtained # in the following way: # # IP: The address is auto detected by checking the peer address # of the socket used by the replica to connect with the master. # # Port: The port is communicated by the replica during the replication # handshake, and is normally the port that the replica is using to # listen for connections. # # However when port forwarding or Network Address Translation (NAT) is # used, the replica may be actually reachable via different IP and port # pairs. The following two options can be used by a replica in order to # report to its master a specific set of IP and port, so that both INFO # and ROLE will report those values. # # There is no need to use both the options if you need to override just # the port or the IP address. # # replica-announce-ip 5.5.5.5 # replica-announce-port 1234

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      43

      44

      45

      46

      47

      48

      49

      50

      51

      52

      53

      54

      55

      56

      57

      58

      59

      60

      61

      62

      63

      64

      65

      66

      67

      68

      69

      70

      71

      72

      73

      74

      75

      76

      77

      78

      79

      80

      81

      82

      83

      84

      85

      86

      87

      88

      89

      90

      91

      92

      93

      94

      95

      96

      97

      98

      99

      100

      101

      102

      103

      104

      105

      106

      107

      108

      109

      110

      111

      112

      113

      114

      115

      116

      117

      118

      119

      120

      121

      122

      123

      124

      125

      126

      127

      128

      129

      130

      131

      132

      133

      134

      135

      136

      137

      138

      139

      140

      141

      142

      143

      144

      145

      146

      147

      148

      149

      150

      151

      152

      153

      154

      155

      156

      157

      158

      159

      160

      161

      162

      163

      164

      165

      166

      167

      168

      169

      170

      171

      172

      173

      174

      175

      176

      177

      178

      179

      180

      181

      182

      183

      184

      185

      186

      187

      188

      189

      190

      191

      192

      193

      194

      195

      196

      197

      198

      199

      200

      201

      202

      203

      204

      205

      206

      207

      208

      209

      210

      211

      212

      213

      214

      215

      216

      217

      218

      219

      220

      221

      222

      223

      224

      225

      226

      227

      228

      229

      230

      231

      232

      233

      234

      235

      236

      237

      238

      239

      240

      241

      242

      243

      244

      245

      246

      247

      248

      249

      250

      251

      252

      253

      254

      255

      256

      257

      258

      259

      260

      261

      262

      263

      主-副本復制。

      使用副本的Redis實例復制另一個Redis服務器。關于Redis復制的一些事情需要了解。

      # +------------------+ +---------------+ # | Master | ---> | Replica | # | (receive writes) | | (exact copy) | # +------------------+ +---------------+

      1

      2

      3

      4

      1)Redis復制是異步的。但是你可以配置一個主服務器,如果它沒有連接到至少給定數量的副本,則停止寫操作。

      2)如果復制鏈接丟失了相對較短的時間,Redis副本能夠執行與主服務器的部分重新同步。您可能希望根據自己的需要配置復制積壓大小(請參閱此文件的下一部分)。

      3)復制是自動的,不需要用戶干預。在網絡分區之后,副本會自動嘗試重新連接主分區并與它們重新同步。

      如果主服務器受密碼保護,會在開始復制同步過程之前告訴副本進行身份驗證,否則主服務器將拒絕復制請求。

      然而,這是不夠的,如果你是使用Redis ACLs (Redis版本6或更高),默認用戶不能夠運行PSYNC命令和/或其他復制所需的命令。在這種情況下,最好配置一個特殊用戶來使用復制,

      指定masteruser配置如下:masteruser

      當指定了masteruser時,副本將使用新的身份驗證表單對其主進行身份驗證:AUTH

      當一個副本失去了它與主的連接,或者當復制仍在進行時,副本將會出現以下兩種情況:

      redis.conf 翻譯與配置(二)【redis6.0.6】

      1)如果將replica-serve-stale-data設置為’yes’(缺省值),該副本仍然會響應客戶機請求,可能會使用過期數據,或者如果這是第一次同步,數據集可能只是空的。

      2)如果copy - service - stal- data被設置為“no”,那么除了INFO、replicaOF、AUTH、PING、SHUTDOWN、REPLCONF、ROLE、CONFIG、SUBSCRIBE、UNSUBSCRIBE、PSUBSCRIBE、PUNSUBSCRIBE、PUBLISH、PUBSUB、COMMAND、POST、HOST:和LATENCY之外,所有類型的命令都會回復一個錯誤“SYNC with master in progress”。

      您可以配置一個副本實例來接受或不接受寫操作。寫副本實例對于存儲一些臨時數據可能很有用(因為寫在副本上的數據在與主服務器重新同步后很容易刪除),但是如果客戶端由于配置錯誤而寫副本,也可能會導致問題。

      (從2.6代版本開始,副本默認只讀)。

      注意:只讀副本的設計不是為了在internet上向不受信任的客戶端公開。它只是防止實例濫用的保護層。

      默認情況下,仍然使用只讀副本導出所有管理命令,如配置、調試等。使用“renmin -command”隱藏所有管理/危險命令,可以在一定程度上提高只讀副本的安全性。

      復制同步策略:磁盤或套接字。

      新的副本和重新連接的副本不能繼續復制過程只是接收差異,需要做所謂的“完全同步”。RDB文件從主服務器傳輸到副本服務器。

      有以下兩種方式進行傳輸:

      1)磁盤備份:Redis主機創建一個新的進程,將RDB文件寫到磁盤上。稍后,該文件由父進程遞增地傳輸到副本。

      2)無磁盤:Redis master創建一個新的進程,直接將RDB文件寫入副本套接字,而不需要接觸磁盤。

      使用磁盤支持的復制,在生成RDB文件時,只要當前生成RDB文件的子文件完成其工作,就可以將更多的副本排隊并與RDB文件一起提供服務。如果在傳輸開始后使用無磁盤復制,到達的新副本將排隊,當當前副本終止時,新的傳輸將開始。

      當使用無磁盤復制時,主服務器在開始傳輸之前等待一段可配置的時間(以秒為單位),希望多個副本到達并并行傳輸。

      對于慢磁盤和快(大帶寬)網絡,無磁盤復制工作得更好。

      當啟用無磁盤復制時,可以配置服務器等待的延遲,以便生成通過套接字將RDB傳輸到副本的子服務器。

      這一點很重要,因為一旦傳輸開始,就不可能為到達的新副本提供服務,這些副本將排隊等待下一次RDB傳輸,因此服務器等待延遲,以便讓更多的副本到達。

      延遲以秒為單位指定,默認情況下為5秒。要完全禁用它,只需將它設置為0秒,傳輸將盡快開始。

      警告:RDB無磁盤加載是試驗性的。由于在這種設置中,副本不會立即將RDB存儲在磁盤上,因此在故障轉移期間可能會導致數據丟失。RDB無磁盤加載+ Redis模塊不處理I/O讀取也可能導致Redis中止在I/O錯誤的情況下。只有你有了絕對權限之后才可以這么做。

      副本可以直接從套接字加載從復制鏈接中讀取的RDB,或者將RDB存儲到一個文件中,并在從主服務器完全接收到該文件后讀取該文件。

      在許多情況下,磁盤比網絡慢,存儲和加載RDB文件可能會增加復制時間(甚至增加寫內存和緩沖緩沖區上的主副本)。

      但是,直接從套接字解析RDB文件可能意味著我們必須在接收到完整的RDB之前刷新當前數據庫的內容。因此,我們有以下選擇:

      “disabled”——不要使用無磁盤加載(首先將rdb文件存儲到磁盤) “on-empty-db”——只有在完全安全的情況下才使用無磁盤加載。 “swapdb”——在直接從套接字解析數據時,在RAM中保留當前db內容的副本。注意,這需要足夠的內存,如果沒有內存,就會面臨OOM被殺死的風險。

      1

      2

      3

      4

      5

      復制按預定義的時間間隔將ping發送到服務器。可以使用repl_ping_replica_period選項更改這個間隔。默認值是10秒。

      以下選項設置復制超時:

      1)從復制的角度看,同步過程中批量傳輸I/O。 2)從副本(data, pings)的角度控制超時。 3)從master(REPLCONF ACK pings)的角度來看副本超時。

      1

      2

      3

      一定要確保此值大于repl-ping-replica-period指定的值,否則每當主服務器和副本之間的流量較低時,就會檢測到超時。

      同步后在復制套接字上禁用TCP_NODELAY ?

      如果你選擇“是”Redis將使用更少的TCP數據包和更少的帶寬發送數據副本。但是這可能會增加數據在副本端出現的延遲,在使用默認配置的Linux內核中,延遲高達40毫秒。

      如果選擇“no”,數據在復制端出現的延遲將會減少,但復制將使用更多的帶寬。

      默認情況下,我們優化的是低延遲,但在流量非常大的情況下,或者當主服務器和副本之間有很多跳距時,將其轉換為“yes”可能是一個好主意。

      設置復制backlog大小。backlog是一個緩沖區,當副本斷開連接一段時間后,它會積累副本數據,因此當副本希望重新連接時,通常不需要完全重新同步,但部分重新同步就足夠了,只需傳遞副本斷開連接時丟失的那部分數據。

      復制積壓越大,副本斷開連接的時間就越長,隨后就能夠執行部分重新同步。

      只在至少有一個副本連接時分配backlog。

      在主服務器不再連接副本一段時間后,backlog將被釋放。以下選項配置從最后一個副本斷開連接開始釋放積壓緩沖區所需的秒數。

      注意,副本永遠不會因為超時而釋放backlog,因為它們可能稍后被提升為主版本,并且應該能夠正確地與副本“部分重新同步”:因此,它們應該始終積累backlog。

      值為0意味著永遠不會釋放積壓。

      副本優先級是由Redis在INFO輸出中發布的一個整數。它被Redis哨兵用來選擇一個副本提升為一個master,如果master不再正常工作。

      優先級較低的副本被認為更適合升級,因此,例如,如果有三個優先級為10,100,25的副本,Sentinel將選擇優先級為10的副本,即優先級最低的副本。

      但是,如果優先級為0,則表示該副本不能執行master的角色,因此Redis Sentinel將永遠不會選擇優先級為0的副本進行升級。

      默認情況下,優先級是100。

      如果連接的副本少于N個,主服務器可以停止接受寫操作,延遲小于或等于M秒。

      N個副本需要處于“在線”狀態。

      以秒為單位的延遲必須是<=指定的值,它是從副本接收到的最后一個ping計算出來的,這個ping通常是每秒發送一次的。

      此選項并不保證N個副本將接受寫操作,但在沒有足夠副本可用的情況下,將丟失寫操作的暴露窗口限制為指定的秒數。

      例如,需要至少3個延遲<= 10秒的副本,使用:

      # min-replicas-to-write 3 # min-replicas-max-lag 10

      1

      2

      將其中一個設置為0將禁用該特性。

      默認情況下,min-replicas-to-write設置為0(禁用特性),min-replicas-max-lag設置為10。

      一個Redis的管理員是能夠列出的地址和端口的附加副本在不同的方式。例如,"INFO replication"部分提供了這個信息,在其他工具中,Redis Sentinel用來找出副本實例。

      該信息可用的另一個地方是master的“ROLE”命令的輸出。

      副本通常報告的所列IP和地址通過以下方式獲取:

      IP:通過檢查副本與主連接使用的套接字的對等地址來自動檢測地址。 Port:該端口在復制握手期間由副本通信,并且通常是副本用于偵聽連接的端口。

      1

      2

      3

      然而,當使用端口轉發或網絡地址轉換(NAT)時,可以通過不同的IP和端口對訪問副本。副本可以使用以下兩個選項向其主人報告一組特定的IP和端口,以便INFO和ROLE都能報告這些值:

      (如果您只需要覆蓋端口或IP地址,則不需要同時使用這兩個選項)

      # replica-announce-ip 5.5.5.5 # replica-announce-port 1234

      1

      2

      追蹤鍵

      原文

      ############################### KEYS TRACKING ################################# # Redis implements server assisted support for client side caching of values. # This is implemented using an invalidation table that remembers, using # 16 millions of slots, what clients may have certain subsets of keys. In turn # this is used in order to send invalidation messages to clients. Please # to understand more about the feature check this page: # # https://redis.io/topics/client-side-caching # # When tracking is enabled for a client, all the read only queries are assumed # to be cached: this will force Redis to store information in the invalidation # table. When keys are modified, such information is flushed away, and # invalidation messages are sent to the clients. However if the workload is # heavily dominated by reads, Redis could use more and more memory in order # to track the keys fetched by many clients. # # For this reason it is possible to configure a maximum fill value for the # invalidation table. By default it is set to 1M of keys, and once this limit # is reached, Redis will start to evict keys in the invalidation table # even if they were not modified, just to reclaim memory: this will in turn # force the clients to invalidate the cached values. Basically the table # maximum size is a trade off between the memory you want to spend server # side to track information about who cached what, and the ability of clients # to retain cached objects in memory. # # If you set the value to 0, it means there are no limits, and Redis will # retain as many keys as needed in the invalidation table. # In the "stats" INFO section, you can find information about the number of # keys in the invalidation table at every given moment. # # Note: when key tracking is used in broadcasting mode, no memory is used # in the server side so this setting is useless. # # tracking-table-max-keys 1000000

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      Redis實現了服務器輔助支持客戶端緩存值。這是使用一個invalidation table(失效表?)實現的,它使用了1600萬個插槽,客戶機可能擁有特定的鍵子集。

      相反的,它用于向客戶端發送invalidation信息。詳情請去下面的網站一探究竟:

      https://redis.io/topics/client-side-caching

      1

      當對客戶端啟用跟蹤時,假設所有只讀查詢都被緩存:這將迫使Redis在invalidation table中存儲信息。

      當鍵值被修改時,這些信息被刷新,舊消息(失效消息)被發送到客戶端。

      然而,如果工作負載主要是讀取,Redis可能會使用越來越多的內存來跟蹤許多客戶端獲取的鍵。

      因此,可以為invalidation table配置最大填充值。默認設置為1M的鍵,一旦達到這個限制,Redis就會開始從invalidation表中移除鍵,即使它們沒有被修改,這樣做只是為了回收內存:這將反過來迫使客戶機將緩存的值清空。

      基本上,表的最大大小是在服務器端用于跟蹤 /你緩存了什么信息的內存/ 和 /客戶機在內存中保留緩存對象的能力/ 之間進行權衡。

      如果你設置的值為0,這意味著沒有限制,Redis將保留invalidation table 所需要的所有鍵。

      在“統計”信息部分,您可以找到關于在每個給定時刻invalidation表中的鍵數的信息。

      注意:在廣播模式下使用鍵值跟蹤時,服務器端不會使用內存,因此此設置無效。

      啊,累啊。。

      Redis 機器翻譯

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:Excel取整函數:簡單易用的數值處理工具
      下一篇:wps如何更改日期格式、
      相關文章
      亚洲Av无码精品色午夜| 亚洲av永久无码精品网站| 亚洲大香人伊一本线| 亚洲午夜免费视频| 亚洲AV无码国产精品麻豆天美| 亚洲精品国产精品乱码不卡√| 亚洲精品无码99在线观看| 亚洲精品老司机在线观看| 亚洲精品成人a在线观看| 亚洲精品网站在线观看不卡无广告| jjzz亚洲亚洲女人| 亚洲av日韩aⅴ无码色老头| 亚洲sm另类一区二区三区| 人人狠狠综合久久亚洲| 亚洲国产高清国产拍精品| 国产成人亚洲精品播放器下载| 亚洲A∨精品一区二区三区| 亚洲成网777777国产精品| 亚洲精品国产精品国自产观看| 亚洲精品老司机在线观看| 亚洲午夜无码久久久久| 亚洲午夜无码久久久久| 亚洲av无码成h人动漫无遮挡| 亚洲国产精品一区二区久久| 精品亚洲一区二区三区在线观看| av在线亚洲欧洲日产一区二区| 亚洲国产精品成人综合色在线| 久久久久亚洲AV无码去区首| 日韩亚洲精品福利| 久久亚洲欧洲国产综合| 亚洲精品无码久久久久sm| 亚洲国产综合91精品麻豆| 亚洲成a人片在线观看播放| 亚洲最大无码中文字幕| 免费观看亚洲人成网站| 久久精品亚洲乱码伦伦中文| 亚洲精品色午夜无码专区日韩| 亚洲综合久久综合激情久久| 亚洲不卡在线观看| 亚洲老熟女五十路老熟女bbw| 国产亚洲成在线播放va|