赞
踩
# Redis配置文件示例。 # Redis configuration file example. # # 注意,为了读取配置文件,Redis必须以文件路径作为第一个参数开始: # Note that in order to read the configuration file, Redis must be # started with the file path as first argument: # # ./redis-server /path/to/redis.conf # 关于单位的说明:当需要内存大小时,可以指定 # Note on units: when memory size is needed, it is possible to specify # # 它通常采用1k 5GB 4M等形式: # it in the usual form of 1k 5GB 4M and so forth: # # 1k => 1000 bytes # 1kb => 1024 bytes # 1m => 1000000 bytes # 1mb => 1024*1024 bytes # 1g => 1000000000 bytes # 1gb => 1024*1024*1024 bytes # # 单元不区分大小写,所以1GB 1GB都是一样的。 # units are case insensitive so 1GB 1Gb 1gB are all the same. ################################## INCLUDES ################################### # # 在此处包含一个或多个其他配置文件。如果您有一个标准的模板,可以连接到所有Redis服务器, # 但也需要自定义每个服务器的一些设置,那么这将非常有用。Include文件可以包含其他文件, # 所以请明智地使用它。 # Include one or more other config files here. This is useful if you # have a standard template that goes to all Redis servers but also need # to customize a few per-server settings. Include files can include # other files, so use this wisely. # # 注意,admin或Redis Sentinel的命令“CONFIG REWRITE”不会重写选项“include”。 # 由于Redis总是使用最后处理的行作为配置指令的值,因此最好将includes放在该文件的开头, # 以避免在运行时覆盖配置更改。 # 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. # # 如果您对使用include覆盖配置选项感兴趣,最好使用include作为最后一行。 # If instead you are interested in using includes to override configuration # options, it is better to use include as the last line. # # include /path/to/local.conf # include /path/to/other.conf ################################## MODULES ##################################### # 启动时加载模块。如果服务器无法加载模块,它将中止。可以使用多个loadmodule指令。 # Load modules at startup. If the server is not able to load modules # it will abort. It is possible to use multiple loadmodule directives. # # loadmodule /path/to/my_module.so # loadmodule /path/to/other_module.so ################################## NETWORK ##################################### # 默认情况下,如果没有指定“bind”配置指令,Redis将侦听服务器上所有可用网络接口的连接。 # 可以使用“bind”配置指令(后跟一个或多个IP地址)只侦听一个或多个选定的接口。 # By default, if no "bind" configuration directive is specified, Redis listens # for connections from all the network interfaces available on the server. # It is possible to listen to just one or multiple selected interfaces using # the "bind" configuration directive, followed by one or more IP addresses. # # 例如: # Examples: # # bind 192.168.1.100 10.0.0.1 # bind 127.0.0.1 ::1 # # ~~~警告~~~如果运行Redis的计算机直接暴露在internet上,绑定到所有接口是危险的, # 会将实例暴露给internet上的所有人。因此,默认情况下,我们取消注释下面的bind指令, # 这将强制Redis只监听IPv4 lookback接口地址(这意味着Redis将只能接受来自运行在 # 同一台计算机上的客户端的连接)。 # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the # internet, binding to all the interfaces is dangerous and will expose the # instance to everybody on the internet. So by default we uncomment the # following bind directive, that will force Redis to listen only into # the IPv4 lookback interface address (this means Redis will be able to # accept connections only from clients running into the same computer it # is running). # # 如果您确定希望您的实例侦听所有接口,只需注释以下行。 # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES # JUST COMMENT THE FOLLOWING LINE. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bind 127.0.0.1 # 保护模式是一层安全保护,以避免Redis实例在internet上被访问和利用。 # Protected mode is a layer of security protection, in order to avoid that # Redis instances left open on the internet are accessed and exploited. # # 打开保护模式时,如果: # When protected mode is on and if: # # 服务器没有使用bind“指令显式绑定到一组地址。 # 1) The server is not binding explicitly to a set of addresses using the # "bind" directive. # # 未配置密码。 # 2) No password is configured. # # 服务器仅接受来自从IPv4和IPv6环回地址127.0.0.1和::1连接的客户端的连接, # 以及来自Unix域套接字的连接。 # The server only accepts connections from clients connecting from the # IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain # sockets. # # 默认情况下,启用保护模式。只有当您确定希望来自其他主机的客户端连接到Redis时才应该禁用它, # 即使没有配置身份验证,也没有使用“bind”指令显式列出一组特定的接口。 # By default protected mode is enabled. You should disable it only if # you are sure you want clients from other hosts to connect to Redis # even if no authentication is configured, nor a specific set of interfaces # are explicitly listed using the "bind" directive. protected-mode yes # 接受指定端口上的连接,默认值为6379(IANA#815344)。 # 如果指定了端口0,Redis将不会侦听TCP套接字。 # Accept connections on the specified port, default is 6379 (IANA #815344). # If port 0 is specified Redis will not listen on a TCP socket. port 6379 # TCP listen()积压工作。 # TCP listen() backlog. # # 在每秒请求数高的环境中,您需要一个高积压工作,以避免客户端连接速度慢的问题。 # 请注意,Linux内核将自动将其截断为/proc/sys/net/core/somaxconn的值, # 因此请确保同时提高somaxconn和tcp\u max\u syn\u 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. tcp-backlog 511 # Unix套接字。 # Unix socket. # # 指定用于侦听传入连接的Unix套接字的路径。没有默认值,因此Redis在未指定时不会侦听unix套接字 # Specify the path for the Unix socket that will be used to listen for # incoming connections. There is no default, so Redis will not listen # on a unix socket when not specified. # # unixsocket /tmp/redis.sock # unixsocketperm 700 # 客户端空闲N秒后关闭连接(0表示禁用) # Close the connection after a client is idle for N seconds (0 to disable) timeout 0 # TCP保持连接。 # TCP keepalive. # # 如果非零,则在没有通信的情况下,使用SO_KEEPALIVE向客户端发送TCP确认。这有两个原因: # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence # of communication. This is useful for two reasons: # # 检测死掉的同伴。 # 1) Detect dead peers. # # 从中间的网络设备的角度来看待连接。 # 2) Take the connection alive from the point of view of network # equipment in the middle. # # 在Linux上,指定的值(以秒为单位)是用于发送ACK的时间段。 # 请注意,要关闭连接,需要两倍的时间。 # 在其他内核上,周期取决于内核配置。 # 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. # # 这个选项的合理值是300秒,这是从redis3.2.1开始的新Redis默认值。 # A reasonable value for this option is 300 seconds, which is the new # Redis default starting with Redis 3.2.1. tcp-keepalive 300 ################################ SNAPSHOTTING ################################ # # 将数据库保存在磁盘上: # Save the DB on disk: # # 保存 <seconds> <changes> # 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. # # 在下面的示例中,行为将会保存: # In the example below the behaviour will be to save: # # 900秒(15分钟)后,如果至少有一个键更改 # after 900 sec (15 min) if at least 1 key changed # # 300秒(5分钟)后,如果至少有10个键更改 # after 300 sec (5 min) if at least 10 keys changed # # 60秒后,如果至少10000个键发生更改 # after 60 sec if at least 10000 keys changed # # 注意:您可以通过注释掉所有“save”行来完全禁用保存。 # Note: you can disable saving completely by commenting out all "save" lines. # # 通过添加带有单个空字符串参数的save指令,也可以删除以前配置的所有保存点,如以下示例所示: # 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 # 默认情况下,如果RDB快照已启用(至少一个保存点),并且最新的后台保存失败,Redis将停止接受写入。 # 这将使用户意识到(以一种强硬的方式)数据没有正确地保存在磁盘上,否则很可能没有人会注意到, # 并且会发生一些灾难。 # 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. # # 如果后台保存过程重新开始工作,Redis将自动再次允许写操作。 # If the background saving process will start working again Redis will # automatically allow writes again. # # 但是,如果您已经设置了对Redis服务器和持久性的正确监视,那么您可能需要禁用此功能, # 以便即使在磁盘、权限等方面出现问题时,Redis仍能正常工作。 # 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 # 转储.rdb数据库时使用LZF压缩字符串对象? # 默认设置为“是”,因为它几乎总是一个胜利。 # 如果您想在saving child中保存一些CPU,请将其设置为“no”,但是如果您有可压缩的值或键, # 则数据集可能会更大。 # 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 # 由于RDB版本5,CRC64校验和放在文件的末尾。 # 这使格式更能抵抗损坏,但在保存和加载RDB文件时,性能会受到影响(约10%), # 因此可以禁用它以获得最大性能。 # 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文件的校验和为零,这将告诉加载代码跳过检查。 # 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 # 工作目录。 # The working directory. # # DB将被写入这个目录,使用上面使用'dbfilename'配置指令指定的文件名。 # 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 ./ ################################# REPLICATION ################################# # 主从复制。使用slaveof使Redis实例成为另一个Redis服务器的副本。 # 关于Redis复制,需要尽快了解的一些事情。 # Master-Slave replication. Use slaveof to make a Redis instance a copy of # another Redis server. A few things to understand ASAP about Redis replication. # # Redis复制是异步的,但是您可以配置一个主设备,如果它看起来没有连接到至少给定数量的从设备, # 那么它就停止接受写操作。 # 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. # # 如果复制链路丢失的时间相对较少,Redis从机可以执行与主机的部分重新同步。 # 您可能需要根据需要使用合理的值来配置复制积压工作大小(请参阅本文件的下一节)。 # 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 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 slaves automatically try to reconnect to masters # and resynchronize with them. # # slaveof <masterip> <masterport> # 如果主机受密码保护(使用下面的“requirepass”配置指令), # 则可以在启动复制同步过程之前通知从机进行身份验证,否则主机将拒绝从机请求。 # 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. # # 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: # # 如果slave serve stale data设置为“yes”(默认值),那么slave仍然会回复客户机请求, # 可能有过期的数据,或者如果这是第一次同步,那么数据集可能是空的。 # 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. # # 如果slave-serve-stale data设置为“no”, # 则slave将以错误“SYNC with master in progress”回复除INFO和SLAVEOF之外的所有命令。 # 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. # 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. # # 因为redis2.6在默认情况下是只读的。 # Since Redis 2.6 by default slaves are read-only. # # 注意:只读从属服务器的设计不允许暴露于internet上不受信任的客户端。 # 它只是一个防止实例被滥用的保护层。 # 默认情况下,只读从设备仍然导出所有管理命令,如CONFIG、DEBUG等。 # 在一定程度上,您可以使用“rename command”来隐藏所有管理/危险命令, # 从而提高只读从机的安全性。 # 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. slave-read-only yes # 复制同步策略:磁盘或套接字。 # Replication SYNC strategy: disk or socket. # # ------------------------------------------------------- # 警告:无盘复制目前处于试验阶段 # WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY # ------------------------------------------------------- # # 新的从机和重新连接的从机如果只是接收到差异而无法继续复制过程, # 则需要执行所谓的“完全同步”。 # RDB文件从主设备传输到从设备。 # 传输有两种不同的方式: # New slaves 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 is transmitted from the master to the slaves. # The transmission can happen in two different ways: # # 磁盘备份:Redis主控程序创建一个新的进程,该进程将RDB文件写入磁盘。 # 之后,父进程将文件增量传输到从属程序。 # 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 slaves incrementally. # 无盘:Redis master创建了一个新进程,直接将RDB文件写入从属套接字,而完全不接触磁盘。 # 2) Diskless: The Redis master creates a new process that directly writes the # RDB file to slave sockets, without touching the disk at all. # # 使用磁盘备份复制,在生成RDB文件的同时,只要生成RDB文件的当前子级完成其工作, # 就可以将更多的从属服务器排队并与RDB文件一起提供服务。如果使用无盘复制,则在传输开始后, # 到达的新从机将排队,当当前传输终止时,新的传输将开始。 # With disk-backed replication, while the RDB file is generated, more slaves # 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 slaves 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 slaves # will arrive and the transfer can be parallelized. # # 对于慢速磁盘和快速(大带宽)网络,无盘复制工作得更好。 # With slow disks and fast (large bandwidth) networks, diskless replication # works better. repl-diskless-sync no # 启用无盘复制时,可以配置服务器等待的延迟,以便生成通过套接字将RDB传输到从属服务器的子级。 # 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 slaves. # # 这一点很重要,因为一旦传输开始,就不可能为到达的新从属服务器提供服务, # 这些从属服务器将排队等待下一次RDB传输,因此服务器会等待一个延迟,以便让更多从属服务器到达。 # This is important since once the transfer starts, it is not possible to serve # new slaves arriving, that will be queued for the next RDB transfer, so the server # waits a delay in order to let more slaves arrive. # # 延迟以秒为单位指定,默认为5秒。要完全禁用它,只需将其设置为0秒,传输将尽快开始。 # 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 # 从属服务器以预定义的间隔向服务器发送ping。可以使用repl_ping_slave_period选项更改此间隔。 # 默认值为10秒。 # 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. # # repl-ping-slave-period 10 # 以下选项设置的复制超时: # The following option sets the replication timeout for: # # 1)从从从机的角度来看,同步期间的批量传输I/O。 # 2)从从机(数据、ping)的角度看主超时。 # 3)从主机的角度来看,从机超时(REPLCONF-ACK pings)。 # 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). # # 务必确保此值大于为repl ping slave period指定的值, # 否则每次主设备和从设备之间的通信量较低时都会检测到超时。 # 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. # # repl-timeout 60 # 同步后在从属套接字上禁用TCP\U节点? # Disable TCP_NODELAY on the slave socket after SYNC? # # 如果您选择“是”,Redis将使用较少的TCP数据包和较少的带宽将数据发送到从属服务器。 # 但是这会增加数据出现在从机端的延迟,对于使用默认配置的Linux内核,最长为40毫秒。 # 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. # # 如果选择“否”,则从机端显示数据的延迟将减少,但复制将使用更多带宽。 # 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. # # 默认情况下,我们会针对低延迟进行优化,但是在流量非常大的情况下, # 或者当主节点和从节点之间有许多跳距时,将此选项改为“是”可能是个好主意。 # 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. repl-disable-tcp-nodelay no # 设置复制积压大小。backlog是一个缓冲区,当从机断开连接一段时间后,它会累积从机数据, # 因此当从机想要再次重新连接时,通常不需要完全重新同步,但部分重新同步就足够了, # 只需传递从机在断开连接时丢失的部分数据。 # 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. # # 复制积压越大,从机可以断开连接的时间就越长,并且以后可以执行部分重新同步。 # The bigger the replication backlog, the longer the time the slave can be # disconnected and later be able to perform a partial resynchronization. # # 只有在至少有一个从机连接时,才会分配backlog。 # The backlog is only allocated once there is at least a slave connected. # # 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. # # 请注意,从机从不为超时释放backlog,因为它们可能稍后升级为主机, # 并且应该能够正确地与从机“部分重新同步”:因此它们应该总是累积backlog。 # Note that slaves never free the backlog for timeout, since they may be # promoted to masters later, and should be able to correctly "partially # resynchronize" with the slaves: hence they should always accumulate backlog. # # 值为0表示从不释放积压工作。 # A value of 0 means to never release the backlog. # # repl-backlog-ttl 3600 # slave priority是Redis在INFO输出中发布的整数。 # Redis Sentinel使用它来选择一个从属设备,以便在主设备不再正常工作时升级为主设备。 # 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. # # 优先级较低的从机被认为更适合提升,因此,例如,如果有三个优先级为10、100、25的从机, # Sentinel将选择优先级为10的从机,这是最低的。 # 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. # # 但是,特殊优先级为0表示从机无法执行主机角色, # 因此Redis Sentinel永远不会选择优先级为0的从机进行升级。 # 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. # # 默认情况下,优先级为100。 # By default the priority is 100. slave-priority 100 # 如果连接的从属设备少于N个,且延迟时间小于或等于M秒,则主设备有可能停止接受写操作。 # 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. # # N个从机需要处于“在线”状态。 # The N slaves need to be in "online" state. # # 滞后时间(以秒为单位)必须<=指定值,它是从从从机接收的最后一次ping(通常每秒发送一次)计算出来的。 # 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. # # 此选项不保证N个复制副本将接受写入, # 但将在没有足够的从副本可用时将丢失写入的暴露窗口限制在指定的秒数内。 # 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 slaves # are available, to the specified number of seconds. # # 例如,要要求至少3个滞后时间小于等于10秒的从机,请使用: # For example to require at least 3 slaves with a lag <= 10 seconds use: # # min-slaves-to-write 3 # min-slaves-max-lag 10 # # 将其中一个设置为0将禁用该功能。 # Setting one or the other to 0 disables the feature. # # 默认情况下,要写入的最小从属设置为0(功能已禁用),最小从属最大滞后设置为10。 # By default min-slaves-to-write is set to 0 (feature disabled) and # min-slaves-max-lag is set to 10. # Redis主机能够以不同的方式列出连接的从机的地址和端口。 # 例如,“信息复制”部分提供了这些信息,Redis Sentinel在其他工具中使用这些信息来发现从属实例。 # 另一个可以获得这些信息的地方是主机的“ROLE”命令的输出。 # A Redis master is able to list the address and port of the attached # slaves 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 slave instances. # Another place where this info is available is in the output of the # "ROLE" command of a master. # # 从机通常报告的列出的IP和地址通过以下方式获得: # The listed IP and address normally reported by a slave is obtained # in the following way: # # IP:通过检查从机用于连接主机的套接字的对等地址自动检测地址。 # IP: The address is auto detected by checking the peer address # of the socket used by the slave to connect with the master. # # 端口:端口在复制握手期间由从机通信,通常是从机用于列出连接的端口。 # Port: The port is communicated by the slave during the replication # handshake, and is normally the port that the slave is using to # list for connections. # # 然而,当使用端口转发或网络地址转换(NAT)时,从机实际上可以通过不同的IP和端口对到达。 # 从属服务器可以使用以下两个选项向其主服务器报告一组特定的IP和端口,以便INFO和ROLE都报告这些值。 # However when port forwarding or Network Address Translation (NAT) is # used, the slave may be actually reachable via different IP and port # pairs. The following two options can be used by a slave in order to # report to its master a specific set of IP and port, so that both INFO # and ROLE will report those values. # # 如果只需要覆盖端口或IP地址,则无需同时使用这两个选项。 # There is no need to use both the options if you need to override just # the port or the IP address. # # slave-announce-ip 5.5.5.5 # slave-announce-port 1234 ################################## SECURITY ################################### # 要求客户端在处理任何其他命令之前发出AUTH<PASSWORD>。 # 在您不信任其他人可以访问运行redis服务器的主机的环境中,这可能很有用。 # 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. # # 为了向后兼容性和大多数人不需要auth(例如,他们运行自己的服务器),这应该被注释掉。 # This should stay commented out for backward compatibility and because most # people do not need auth (e.g. they run their own servers). # # 警告:由于Redis速度非常快,外部用户可以在一个好的盒子上每秒尝试多达150k个密码。 # 这意味着你应该使用一个非常强大的密码,否则它将很容易被打破。 # 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. # # requirepass foobared # 命令重命名。 # Command renaming. # # 可以在共享环境中更改危险命令的名称。例如,CONFIG命令可能会被重命名为一些难以猜测的内容, # 这样它仍然可以用于内部使用工具,但不可用于一般客户机。 # 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. # # 例如: # Example: # # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 # # 也可以通过将命令重命名为空字符串来完全终止命令: # It is also possible to completely kill a command by renaming it into # an empty string: # # rename-command CONFIG "" # # 请注意,更改登录到AOF文件或传输到从属服务器的命令的名称可能会导致问题。 # Please note that changing the name of commands that are logged into the # AOF file or transmitted to slaves may cause problems. ################################### CLIENTS #################################### # 设置同时连接的最大客户端数。默认情况下,此限制设置为10000个客户端, # 但是如果Redis服务器无法配置进程文件限制以允许指定的限制, # 则允许的最大客户端数将设置为当前文件限制减去32(因为Redis保留了一些文件描述符供内部使用)。 # 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). # # 一旦达到限制,Redis将关闭所有新连接,并发送一个错误“max number of clients reached”。 # Once the limit is reached Redis will close all the new connections sending # an error 'max number of clients reached'. # # maxclients 10000 ############################## MEMORY MANAGEMENT ################################ # 将内存使用限制设置为指定的字节数。 # 当达到内存限制时,Redis将根据所选的逐出策略(参见maxmemory策略)尝试删除密钥。 # Set a memory usage limit to 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). # # 如果Redis无法根据策略删除密钥,或者如果策略设置为“noeviction”, # Redis将开始以错误的方式答复使用更多内存的命令,如set、LPUSH等,并将继续答复GET等只读命令。 # 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作为LRU或LFU缓存,或者为实例设置硬内存限制(使用“noeviction”策略)时,此选项通常很有用 # This option is usually useful when using Redis as an LRU or LFU cache, or to # set a hard memory limit for an instance (using the 'noeviction' policy). # # 警告:如果在maxmemory打开的情况下将从属服务器连接到实例, # 则从已用内存计数中减去为从属服务器提供数据所需的输出缓冲区的大小, # 这样网络问题/重新同步就不会触发退出密钥的循环,反过来,从机的输出缓冲区充满了被逐出的密钥的del, # 从而触发了更多密钥的删除,以此类推,直到数据库完全清空。 # 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. # # 总之...如果您连接了从机,建议您设置maxmemory的下限, # 以便系统上有一些可用RAM用于从机输出缓冲区(但如果策略为“noeviction”,则不需要这样做)。 # 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'). # # maxmemory <bytes> # MAXMEMORY策略:当到达MAXMEMORY时,Redis将如何选择要删除的内容。您可以从五种行为中选择: # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory # is reached. You can select among five behaviors: # # 在具有过期集的密钥中使用近似的LRU逐出。 # volatile-lru -> Evict using approximated LRU among the keys with an expire set. # # 使用近似的LRU逐出任何密钥。 # allkeys-lru -> Evict any key using approximated LRU. # # 在具有过期集的键中使用近似LFU逐出。 # volatile-lfu -> Evict using approximated LFU among the keys with an expire set. # # 使用近似LFU逐出任何键。 # allkeys-lfu -> Evict any key using approximated LFU. # # 从具有过期集的密钥中移除随机密钥。 # volatile-random -> Remove a random key among the ones with an expire set. # # 删除随机键,任意键。 # allkeys-random -> Remove a random key, any key. # # 删除过期时间最近的密钥(次要TTL) # volatile-ttl -> Remove the key with the nearest expire time (minor TTL) # # 不逐出任何内容,只返回一个写操作错误。 # noeviction -> Don't evict anything, just return an error on write operations. # # LRU表示最近最少使用 # LRU means Least Recently Used # # LFU表示使用频率最低 # LFU means Least Frequently Used # # LRU、LFU和volatile-ttl均采用近似随机算法实现。 # Both LRU, LFU and volatile-ttl are implemented using approximated # randomized algorithms. # # 注意:对于上述任何策略,Redis都会在写操作时返回一个错误,因为没有合适的键来逐出。 # Note: with any of the above policies, Redis will return an error on write # operations, when there are no suitable keys for eviction. # # 在编写之日,这些命令是: # At the date of writing these 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: # # maxmemory-policy noeviction # LRU、LFU和minimal-TTL算法不是精确算法,而是近似算法(为了节省内存),因此您可以调整它的速度或精度。 # 对于默认Redis将检查五个键并选择最近使用较少的键,您可以使用以下配置指令更改样本大小。 # LRU, LFU 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. # # 默认值5会产生足够好的结果。10非常接近真实的LRU,但需要更多的CPU。3更快,但不是很准确。 # The default of 5 produces good enough results. 10 Approximates very closely # true LRU but costs more CPU. 3 is faster but not very accurate. # # maxmemory-samples 5 ############################# LAZY FREEING #################################### # Redis有两个删除键的原语。一个称为DEL,是对象的阻塞删除。这意味着服务器停止处理新命令, # 以便以同步方式回收与对象关联的所有内存。如果删除的键与一个小对象相关联, # 那么执行DEL命令所需的时间非常少,与Redis中的大多数其他O(1)或O(logn)命令相当。 # 但是,如果密钥与包含数百万个元素的聚合值相关联,则服务器可以阻塞很长时间(甚至几秒钟)以完成操作。 # Redis has two primitives to delete keys. One is called DEL and is a blocking # deletion of the object. It means that the server stops processing new commands # in order to reclaim all the memory associated with an object in a synchronous # way. If the key deleted is associated with a small object, the time needed # in order to execute the DEL command is very small and comparable to most other # O(1) or O(log_N) commands in Redis. However if the key is associated with an # aggregated value containing millions of elements, the server can block for # a long time (even seconds) in order to complete the operation. # # 基于上述原因,Redis还提供了UNLINK(non-blocking DEL)和FLUSHDB命令的ASYNC选项等非阻塞删除原语, # 以便在后台回收内存。这些命令在固定时间内执行。另一个线程将尽可能快地增量释放背景中的对象。 # For the above reasons Redis also offers non blocking deletion primitives # such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and # FLUSHDB commands, in order to reclaim memory in background. Those commands # are executed in constant time. Another thread will incrementally free the # object in the background as fast as possible. # # FLUSHDB和FLUSHDB的DEL、UNLINK和ASYNC选项由用户控制。 # 应用程序的设计决定了何时使用其中一个是好主意。然而,Redis服务器有时不得不删除密钥或刷新整个数据库, # 作为其他操作的副作用。具体来说,在以下场景中,Redis独立于用户调用删除对象: # DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled. # It's up to the design of the application to understand when it is a good # idea to use one or the other. However the Redis server sometimes has to # delete keys or flush the whole database as a side effect of other operations. # Specifically Redis deletes objects independently of a user call in the # following scenarios: # # 逐出时,由于maxmemory和maxmemory策略配置,为了给新数据腾出空间,而不超过指定的内存限制。 # 1) On eviction, because of the maxmemory and maxmemory policy configurations, # in order to make room for new data, without going over the specified # memory limit. # # 因为expire:当必须从内存中删除具有相关生存时间的密钥(请参阅expire命令)时。 # 2) Because of expire: when a key with an associated time to live (see the # EXPIRE command) must be deleted from memory. # # 因为命令的一个副作用是在一个可能已经存在的键上存储数据。 # 例如,当用另一个密钥内容替换旧密钥内容时,RENAME命令可能会删除它。 # 类似地,SUNIONSTORE或SORT with STORE选项可能会删除现有密钥。 # SET命令本身删除指定键的任何旧内容,以便用指定的字符串替换它。 # 3) Because of a side effect of a command that stores data on a key that may # already exist. For example the RENAME command may delete the old key # content when it is replaced with another one. Similarly SUNIONSTORE # or SORT with STORE option may delete existing keys. The SET command # itself removes any old content of the specified key in order to replace # it with the specified string. # # 在复制过程中,当从机与其主机执行完全重新同步时,整个数据库的内容将被删除, # 以便加载刚刚传输的RDB文件。 # 4) During replication, when a slave performs a full resynchronization with # its master, the content of the whole database is removed in order to # load the RDB file just transfered. # # 在上述所有情况下,默认情况是以阻塞方式删除对象,就像调用DEL一样。 # 但是,您可以使用以下配置指令专门配置每种情况,以非阻塞方式释放内存,就像调用UNLINK一样: # In all the above cases the default is to delete objects in a blocking way, # like if DEL was called. However you can configure each case specifically # in order to instead release memory in a non-blocking way like if UNLINK # was called, using the following configuration directives: lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no slave-lazy-flush no ############################## APPEND ONLY MODE ############################### # 默认情况下,Redis将数据集异步转储到磁盘上。这种模式在许多应用程序中已经足够好了, # 但是Redis进程出现问题或断电可能会导致几分钟的写丢失(取决于配置的保存点)。 # 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). # # 仅附加文件是一种可选的持久性模式,它提供了更好的持久性。 # 例如,如果使用默认的数据fsync策略(见后面的配置文件), # Redis可能会在服务器断电之类的戏剧性事件中丢失一秒钟的写操作,或者如果Redis进程本身发生错误, # 但操作系统仍然正常运行,则会丢失一次写操作。 # 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. # # AOF和RDB持久性可以同时启用而不会出现问题。 # 如果启动时启用了AOF,Redis将加载AOF,即具有更好持久性保证的文件。 # 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. # # Please check http://redis.io/topics/persistence for more information. appendonly no # 仅附加文件的名称(默认值:“appendonly.aof”) # The name of the append only file (default: "appendonly.aof") appendfilename "appendonly.aof" # fsync()调用告诉操作系统实际将数据写入磁盘,而不是等待输出缓冲区中的更多数据。 # 有些操作系统真的会在磁盘上刷新数据,有些操作系统只会尝试尽快这样做。 # The fsync() call tells the Operating System to actually write data on disk # instead of waiting 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. # # Redis支持三种不同的模式: # Redis supports three different modes: # # 否:不要fsync,只要让操作系统在需要时刷新数据即可。更快。 # 总是:每次写入仅附加日志后进行fsync。慢,最安全。 # everysec: fsync每秒只同步一次。妥协。 # no: don't fsync, just let the OS flush the data when it wants. Faster. # always: fsync after every write to the append only log. Slow, Safest. # everysec: fsync only one time every second. Compromise. # # 默认值是“everysec”,因为这通常是速度和数据安全之间的正确折衷。这是由你来理解, # 如果你可以放松这个“否”,这将让操作系统刷新输出缓冲器当它想要的, # 为了更好的性能(但如果你能生活在一些数据丢失的想法,考虑默认持久模式的快照),或相反, # 使用“总是”这是非常缓慢,但有点比everysec安全。 # 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. # # 更多详情请查看以下文章: # More details please check the following article: # http://antirez.com/post/redis-persistence-demystified.html # # 如果不确定,请使用“everysec”。 # If unsure, use "everysec". # appendfsync always appendfsync everysec # appendfsync no # 当AOF fsync策略设置为always或everysec,并且后台保存进程(后台保存或AOF日志后台重写) # 正在对磁盘执行大量I/O时,在某些Linux配置中,Redis可能会在fsync()调用上阻塞太长时间。 # 请注意,目前还没有解决此问题的方法,因为即使在不同的线程中执行fsync, # 也会阻止我们的同步写入(2)调用。 # 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. # # 为了缓解此问题,可以使用以下选项,以防止在进行BGSAVE或BGREWRITEAOF时在主进程中调用fsync()。 # 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. # # 这意味着,当另一个孩子在储蓄时,Redis的持久性与“appendfsync none”相同。 # 实际上,这意味着在最坏的情况下(使用默认的Linux设置),可能会丢失最多30秒的日志。 # 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). # # 如果您有延迟问题,请将此设置为“是”。否则,从耐久性的角度来看,选择“否”是最安全的。 # 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. no-appendfsync-on-rewrite no # 自动重写仅附加的文件。 # Redis能够在AOF日志大小以指定的百分比增长时自动重写隐式调用BGREWRITEAOF的日志文件。 # 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. # # 工作原理是这样的:Redis会记住最近一次重写后AOF文件的大小 # (如果重启后没有发生重写,则使用启动时AOF的大小)。 # 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). # # 此基本大小与当前大小进行比较。如果当前大小大于指定的百分比,则会触发重写。 # 您还需要为要重写的AOF文件指定一个最小大小,这对于避免重写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. # # 指定0的百分比以禁用自动AOF重写功能。 # Specify a percentage of zero in order to disable the automatic AOF # rewrite feature. auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb # 在Redis启动过程的最后,当AOF数据被加载回内存时,可能会发现AOF文件被截断。 # 当运行Redis的系统崩溃时,尤其是在没有data=ordered选项的情况下挂载ext4文件系统时, # 可能会发生这种情况(但是当Redis本身崩溃或中止但操作系统仍然正常工作时,这种情况就不会发生)。 # An AOF file may be found to be truncated at the end during the Redis # startup process, when the AOF data gets loaded back into memory. # This may happen when the system where Redis is running # crashes, especially when an ext4 filesystem is mounted without the # data=ordered option (however this can't happen when Redis itself # crashes or aborts but the operating system still works correctly). # # Redis可以在发生这种情况时带着错误退出,也可以加载尽可能多的数据(现在是默认值), # 如果发现AOF文件在末尾被截断,就可以启动。以下选项控制此行为。 # Redis can either exit with an error when this happens, or load as much # data as possible (the default now) and start if the AOF file is found # to be truncated at the end. The following option controls this behavior. # # 如果aof load TREATED设置为“是”,则加载截断的aof文件,Redis服务器将开始发出日志,以通知用户事件。 # 否则,如果选项设置为“否”,则服务器会因错误中止,拒绝启动。 # 当选项设置为否时,用户需要在重新启动服务器之前使用“redis check AOF”实用程序修复AOF文件。 # If aof-load-truncated is set to yes, a truncated AOF file is loaded and # the Redis server starts emitting a log to inform the user of the event. # Otherwise if the option is set to no, the server aborts with an error # and refuses to start. When the option is set to no, the user requires # to fix the AOF file using the "redis-check-aof" utility before to restart # the server. # # 注意,如果发现AOF文件在中间被损坏,服务器仍将退出一个错误。 # 此选项仅适用于Redis尝试从AOF文件读取更多数据但找不到足够字节的情况。 # Note that if the AOF file will be found to be corrupted in the middle # the server will still exit with an error. This option only applies when # Redis will try to read more data from the AOF file but not enough bytes # will be found. aof-load-truncated yes # 当重写AOF文件时,Redis能够在AOF文件中使用RDB前导码,以实现更快的重写和恢复。 # 启用此选项后,重写的AOF文件由两个不同的节组成: # When rewriting the AOF file, Redis is able to use an RDB preamble in the # AOF file for faster rewrites and recoveries. When this option is turned # on the rewritten AOF file is composed of two different stanzas: # # [RDB file][AOF tail] # # 加载Redis时,会识别出AOF文件以“Redis”字符串开头,并加载前缀RDB文件,然后继续加载AOF尾部。 # When loading Redis recognizes that the AOF file starts with the "REDIS" # string and loads the prefixed RDB file, and continues loading the AOF # tail. # # 当前默认情况下,此选项处于关闭状态,以避免格式更改带来的意外情况,但在某些时候将用作默认值。 # This is currently turned off by default in order to avoid the surprise # of a format change, but will at some point be used as the default. aof-use-rdb-preamble no ################################ LUA SCRIPTING ############################### # Lua脚本的最大执行时间(毫秒)。 # Max execution time of a Lua script in milliseconds. # # 如果达到最大执行时间,Redis将记录在允许的最长时间之后脚本仍在执行中,并将开始回复有错误的查询。 # 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. # # 当长时间运行的脚本超过最大执行时间时,只有脚本KILL和SHUTDOWN NOSAVE命令可用。 # 第一个命令可用于停止尚未调用write命令的脚本。 # 第二种方法是在脚本已经发出写入命令但用户不想等待脚本自然终止的情况下关闭服务器的唯一方法。 # When a long running script exceeds 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 command was # already issued by the script but the user doesn't want to wait for the natural # termination of the script. # # 将其设置为0或负值,以便在没有警告的情况下无限执行。 # Set it to 0 or a negative value for unlimited execution without warnings. lua-time-limit 5000 ################################ REDIS CLUSTER ############################### # # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # 警告:Redis集群被认为是稳定的代码,但是为了将其标记为“成熟”, # 我们需要等待相当一部分用户将其部署到生产环境中。 # WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however # in order to mark it as "mature" we need to wait for a non trivial percentage # of users to deploy it in production. # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # 普通Redis实例不能是Redis集群的一部分;只有作为群集节点启动的节点才能启动。 # 要将Redis实例启动为群集节点,请启用群集支持,取消注释以下内容: # 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: # # cluster-enabled yes # 每个集群节点都有一个集群配置文件。此文件不可手动编辑。它由Redis节点创建和更新。 # 每个Redis集群节点都需要不同的集群配置文件。 # 确保在同一系统中运行的实例没有重叠的群集配置文件名。 # 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 do not have # overlapping cluster configuration file names. # # cluster-config-file nodes-6379.conf # Cluster node timeout是节点必须无法访问才能被视为处于故障状态的毫秒数。 # 大多数其他内部时间限制是节点超时的倍数。 # 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. # # cluster-node-timeout 15000 #如果发生故障的主设备的从属设备的数据看起来太旧,它将避免启动故障转移。 # A slave of a failing master will avoid to start a failover if its data # looks too old. # # 从机没有简单的方法可以精确测量其“数据年龄”,因此执行以下两项检查: # There is no simple way for a slave to actually have an exact measure of # its "data age", so the following two checks are performed: # # 如果有多个从属设备能够进行故障切换,它们会交换消息, # 以便尝试为具有最佳复制偏移量的从属设备提供优势(从主设备处理更多数据)。 # 从属服务器将尝试通过偏移量获得它们的秩,并在故障转移开始时应用与它们的秩成比例的延迟。 # 1) If there are multiple slaves able to failover, they exchange messages # in order to try to give an advantage to the slave with the best # replication offset (more data from the master processed). # Slaves will try to get their rank by offset, and apply to the start # of the failover a delay proportional to their rank. # # 每个从机计算最后一次与主机交互的时间。这可以是接收到的最后一次ping或命令 # (如果主机仍处于“已连接”状态),也可以是与主机断开连接后经过的时间(如果复制链路当前已关闭)。 # 如果上一次交互太旧,从机将根本不尝试故障转移。 # 2) Every single slave computes the time of the last interaction with # its master. This can be the last ping or command received (if the master # is still in the "connected" state), or the time that elapsed since the # disconnection with the master (if the replication link is currently down). # If the last interaction is too old, the slave will not try to failover # at all. # # 点“2”可由用户调整。具体来说,如果自上次与主设备交互以来,所用时间大于以下时间, # 则从设备将不会执行故障转移: # The point "2" can be tuned by user. Specifically a slave will not perform # the failover if, since the last interaction with the master, the time # elapsed is greater than: # # (node-timeout * slave-validity-factor) + repl-ping-slave-period # # 因此,例如,如果节点超时为30秒,从机有效性系数为10,并且假设默认的repl ping slave周期为10秒, # 那么如果从机无法与主机通信的时间超过310秒,它将不会尝试故障转移。 # So for example if node-timeout is 30 seconds, and the slave-validity-factor # is 10, and assuming a default repl-ping-slave-period of 10 seconds, the # slave will not try to failover if it was not able to talk with the master # for longer than 310 seconds. # # 较大的从属有效性因子可能允许数据太旧的从属设备故障切换到主设备, # 而太小的值可能会阻止集群选择从属设备。 # A large slave-validity-factor may allow slaves with too old data to failover # a master, while a too small value may prevent the cluster from being able to # elect a slave at all. # # 为了获得最大可用性,可以将从属有效性因子设置为0,这意味着从属服务器将始终尝试故障转移主服务器, # 而不管它们上次与主服务器交互的时间是什么时候。 #(然而,他们总是尝试应用与他们的偏移等级成比例的延迟)。 # For maximum availability, it is possible to set the slave-validity-factor # to a value of 0, which means, that slaves will always try to failover the # master regardless of the last time they interacted with the master. # (However they'll always try to apply a delay proportional to their # offset rank). # # 零是唯一一个能够保证当所有分区恢复时,集群始终能够继续的值。 # Zero is the only value able to guarantee that when all the partitions heal # the cluster will always be able to continue. # # cluster-slave-validity-factor 10 # 集群从机能够迁移到孤立的主机,即没有工作从机的主机。这提高了集群抵抗失败的能力, # 因为如果孤立的主服务器没有工作的从属服务器,那么它就不能在发生故障时进行故障转移。 # 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. # # 只有当他们的老主人至少还有一定数量的其他奴隶在工作时,奴隶才会迁移到孤儿主人那里。 # 这个数字就是“移民壁垒”。迁移屏障为1意味着一个从机只有在其主机至少有一个其他工作从机时才会迁移, # 以此类推。它通常反映集群中每个主服务器所需的从属服务器数量。 # 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. # # 默认值为1(从属服务器仅在其主服务器至少保留一个从属服务器时迁移)。 # 要禁用迁移,只需将其设置为非常大的值。 # 可以设置值0,但仅对调试有用,在生产中很危险。 # 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. # # cluster-migration-barrier 1 # 默认情况下,如果Redis集群节点检测到至少有一个散列槽未覆盖(没有可用的节点为其提供服务), # 那么它们将停止接受查询。 # 这样,如果集群部分关闭(例如,一系列哈希槽不再覆盖),那么所有集群最终都将不可用。 # 一旦所有插槽被覆盖,它就会自动返回可用状态。 # By default Redis Cluster nodes stop accepting queries if they detect there # is at least an hash slot uncovered (no available node is serving it). # This way if the cluster is partially down (for example a range of hash slots # are no longer covered) all the cluster becomes, eventually, unavailable. # It automatically returns available as soon as all the slots are covered again. # # 但是,有时您希望正在工作的集群的子集继续接受对仍然覆盖的密钥空间部分的查询。 # 为此,只需将cluster require full coverage选项设置为no。 # However sometimes you want the subset of the cluster which is working, # to continue to accept queries for the part of the key space that is still # covered. In order to do so, just set the cluster-require-full-coverage # option to no. # # cluster-require-full-coverage yes # 此选项设置为“是”时,可防止从机在主机故障期间尝试故障转移其主机。 # 但是,如果强制执行手动故障切换,则主设备仍然可以执行手动故障切换。 # This option, when set to yes, prevents slaves from trying to failover its # master during master failures. However the master can still perform a # manual failover, if forced to do so. # # 这在不同的场景中非常有用,特别是在多个数据中心操作的情况下,如果没有发生完全的DC故障, # 我们希望其中一方永远不会得到提升。 # This is useful in different scenarios, especially in the case of multiple # data center operations, where we want one side to never be promoted if not # in the case of a total DC failure. # # cluster-slave-no-failover no # 为了设置集群,请务必阅读文档 # In order to setup your cluster make sure to read the documentation # available at http://redis.io web site. ########################## CLUSTER DOCKER/NAT support ######################## # 在某些部署中,Redis集群节点地址发现失败,原因是地址被NAT-ted或端口被转发 # (典型的情况是Docker和其他容器)。 # In certain deployments, Redis Cluster nodes address discovery fails, because # addresses are NAT-ted or because ports are forwarded (the typical case is # Docker and other containers). # # 为了使Redis集群在这样的环境中工作,需要一个静态配置,其中每个节点都知道自己的公共地址。 # 以下两个选项用于此范围,分别是: # In order to make Redis Cluster working in such environments, a static # configuration where each node knows its public address is needed. The # following two options are used for this scope, and are: # # * cluster-announce-ip # * cluster-announce-port # * cluster-announce-bus-port # # 每个节点都指示节点其地址、客户机端口和集群消息总线端口。然后在总线包的报头中发布信息, # 以便其他节点能够正确映射发布信息的节点的地址。 # Each instruct the node about its address, client port, and cluster message # bus port. The information is then published in the header of the bus packets # so that other nodes will be able to correctly map the address of the node # publishing the information. # # 如果不使用上述选项,将使用正常的Redis集群自动检测。 # If the above options are not used, the normal Redis Cluster auto-detection # will be used instead. # # 请注意,重新映射时,总线端口可能不在客户端端口+10000的固定偏移量处, # 因此您可以根据重新映射的方式指定任何端口和总线端口。如果没有设置总线端口, # 则通常使用10000的固定偏移量。 # Note that when remapped, the bus port may not be at the fixed offset of # clients port + 10000, so you can specify any port and bus-port depending # on how they get remapped. If the bus-port is not set, a fixed offset of # 10000 will be used as usually. # # Example: # # cluster-announce-ip 10.1.1.5 # cluster-announce-port 6379 # cluster-announce-bus-port 6380 ################################## SLOW LOG ################################### # Redis Slow Log是一个系统,用于记录超出指定执行时间的查询。 # 执行时间不包括与客户端交谈、发送应答等I/O操作,而是实际执行命令所需的时间 # (这是命令执行的唯一阶段,线程被阻塞,同时无法服务其他请求)。 # 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为了记录命令要超过的执行时间(以微秒为单位), # 另一个参数是慢日志的长度。记录新命令时,将从记录的命令队列中删除最旧的命令。 # 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. #下面的时间以微秒表示,因此1000000相当于1秒。请注意,负数将禁用慢速日志,而零值将强制记录每个命令。 # 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. slowlog-log-slower-than 10000 # 这个长度没有限制。只是要注意它会消耗内存。 # 您可以通过SLOWLOG RESET回收慢日志使用的内存。 # 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. slowlog-max-len 128 ################################ LATENCY MONITOR ############################## # Redis延迟监控子系统在运行时对不同的操作进行采样,以便收集与Redis实例的可能延迟源相关的数据。 # The Redis latency monitoring subsystem samples different operations # at runtime in order to collect data related to possible sources of # latency of a Redis instance. # # 通过LATENCY命令,该信息可供可以打印图形和获取报告的用户使用。 # Via the LATENCY command this information is available to the user that can # print graphs and obtain reports. # # 系统仅记录在等于或大于通过延迟监视器阈值配置指令指定的毫秒数的时间内执行的操作。 # 当其值设置为零时,延迟监视器将关闭。 # The system only logs operations that were performed in a time equal or # greater than the amount of milliseconds specified via the # latency-monitor-threshold configuration directive. When its value is set # to zero, the latency monitor is turned off. # # 默认情况下,延迟监视是禁用的,因为如果没有延迟问题,通常不需要延迟监视, # 并且收集数据会对性能产生影响,虽然影响很小,但可以在大负载下进行测量。 #如果需要,可以在运行时使用命令“CONFIG SET Latency monitor threshold<millishes>”轻松启用延迟监视 # By default latency monitoring is disabled since it is mostly not needed # if you don't have latency issues, and collecting data has a performance # impact, that while very small, can be measured under big load. Latency # monitoring can easily be enabled at runtime using the command # "CONFIG SET latency-monitor-threshold <milliseconds>" if needed. latency-monitor-threshold 0 ############################# EVENT NOTIFICATION ############################## # Redis可以将密钥空间中发生的事件通知Pub/Sub客户机。 # 此功能记录在http://redis.io/topics/notifications # Redis can notify Pub/Sub clients about events happening in the key space. # This feature is documented at http://redis.io/topics/notifications # # 例如,如果启用了keyspace events通知,并且客户端对存储在数据库0中的键“foo”执行DEL操作, # 则将通过Pub/Sub发布两条消息: # 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: # # PUBLISH __keyspace@0__:foo del # PUBLISH __keyevent@0__:del foo # # 可以在一组类中选择Redis将通知的事件。每个类都由一个字符标识: # It is possible to select the events that Redis will notify among a set # of classes. Every class is identified by a single character: # # 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. # # “notify keyspace events”将由零个或多个字符组成的字符串作为参数。空字符串表示已禁用通知。 # The "notify-keyspace-events" takes as argument a string that is composed # of zero or multiple characters. The empty string means that notifications # are disabled. # # 示例:要启用列表和常规事件,请从事件名称的角度使用: # Example: to enable list and generic events, from the point of view of the # event name, use: # # notify-keyspace-events Elg # # 示例2:获取订阅频道名称的过期密钥流__keyevent@0__:过期使用: # Example 2: to get the stream of the expired keys subscribing to channel # name __keyevent@0__:expired use: # # notify-keyspace-events Ex # # 默认情况下,所有通知都被禁用,因为大多数用户不需要此功能,而且该功能有一些开销。 # 注意,如果您没有指定至少一个K或E,则不会传递任何事件。 # 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. 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. hash-max-ziplist-entries 512 hash-max-ziplist-value 64 # 列表也以一种特殊的方式编码以节省大量空间。 # 每个内部列表节点允许的条目数可以指定为固定的最大大小或最大元素数。 # 对于固定的最大大小,使用-5到-1,意思是: # Lists are also encoded in a special way to save a lot of space. # The number of entries allowed per internal list node can be specified # as a fixed maximum size or a maximum number of elements. # For a fixed maximum size, use -5 through -1, meaning: # -5: max size: 64 Kb <-- not recommended for normal workloads ## 不建议用于正常工作负载 # -4: max size: 32 Kb <-- not recommended ## 未推荐的 # -3: max size: 16 Kb <-- probably not recommended ## 可能不推荐 # -2: max size: 8 Kb <-- good # -1: max size: 4 Kb <-- good # # 正数表示每个列表节点最多可存储的元素数。 # Positive numbers mean store up to _exactly_ that number of elements # per list node. # # 最高性能的选项通常是-2(8KB大小)或-1(4KB大小), # 但是如果您的用例是唯一的,则根据需要调整设置。 # The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size), # but if your use case is unique, adjust the settings as necessary. list-max-ziplist-size -2 # 列表也可以被压缩。 # Compress depth是要从压缩中*排除*的列表*每*侧的quicklist ziplist节点数。名单的头尾 # 对于快速的push/pop操作总是解压缩的。设置为: # Lists may also be compressed. # Compress depth is the number of quicklist ziplist nodes from *each* side of # the list to *exclude* from compression. The head and tail of the list # are always uncompressed for fast push/pop operations. Settings are: # 0: disable all list compression ## 禁用所有列表压缩 # # 深度1表示“在列表中的1个节点之后才开始压缩,从头部或尾部开始” # 1: depth 1 means "don't start compressing until after 1 node into the list, # going from either the head or tail" # So: [head]->node->node->...->node->[tail] # [head], [tail] will always be uncompressed; inner nodes will compress. # 2: [head]->[next]->node->node->...->node->[prev]->[tail] # 这里的意思是:不压缩head或head->next或tail->prev或tail,而是压缩它们之间的所有节点。 # 2 here means: don't compress head or head->next or tail->prev or tail, # but compress all nodes between them. # 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail] # etc. list-compress-depth 0 # 在一种情况下,集合有一种特殊的编码方式:当一个集合由恰好是基数10中的整数的字符串组成时, # 这些字符串的范围是64位有符号整数。 # 以下配置设置设置集合大小的限制,以便使用此特殊的内存节省编码。 # Sets have a special encoding in just one case: when a set is composed # of just strings that happen 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. 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: zset-max-ziplist-entries 128 zset-max-ziplist-value 64 # HyperLogLog稀疏表示字节数限制。限制包括16字节头。 # 当使用稀疏表示的超对数超过这个极限时,它将转换为稠密表示。 # 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. # # 大于16000的值是完全无用的,因为在这一点上,密集表示更高效。 # A value greater than 16000 is totally useless, since at that point the # dense representation is more memory efficient. # # 建议值为~3000,以便在不减慢太多PFADD的情况下具有节省空间的编码的优点,这对于稀疏编码是O(N)。 # 当CPU不是问题,但空间是问题,并且数据集由基数在0-15000范围内的许多超日志组成时, # 该值可以提高到~10000。 # 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 # 活动重新灰化使用每100毫秒CPU时间1毫秒,以帮助重新设置主Redis哈希表(将顶级键映射到值的表)。 # 哈希表实现Redis使用(请参见dict.c)执行惰性重灰化:当您遇到正在重新灰化的哈希表中的操作越多, # 执行的“步骤”就越多,因此如果服务器空闲,则重新灰化永远不会完成,哈希表将使用更多内存。 # 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. # # 默认情况下,每秒使用10次此毫秒,以便主动地重新刷新主词典,尽可能释放内存。 # The default is to use this millisecond 10 times every second in order to # actively rehash the main dictionaries, freeing memory when possible. # # 如果不确定: # 如果您有严格的延迟要求,那么使用“activerehashing no”,在您的环境中, # Redis可以不时地以2毫秒的延迟回复查询并不是一件好事。 # 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 from time to time # to queries with 2 milliseconds delay. # # 如果您没有这样的硬性要求,但希望尽快释放内存,请使用“activerehashing yes”。 # use "activerehashing yes" if you don't have such hard requirements but # want to free memory asap when possible. activerehashing yes # 客户机输出缓冲区限制可用于强制断开由于某种原因从服务器读取数据速度不够快的客户机的连接 # (一个常见的原因是Pub/Sub客户机不能像发布服务器生成消息那样快地使用消息)。 # 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 including MONITOR clients ## 普通客户端包括监控客户端 # slave -> slave 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). # # 因此,例如,如果硬限制为32兆字节,软限制为16兆字节/10秒,则如果输出缓冲区的大小达到32兆字节, # 客户端将立即断开连接,但如果客户端达到16兆字节并连续克服限制10秒,客户端也将断开连接。 # 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. # # 相反,对于pubsub和slave客户机有一个默认限制,因为订阅者和从属客户端以推送方式接收数据。 # 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 # 客户端查询缓冲区积累新命令。默认情况下,它们被限制为固定数量,以避免协议取消同步 #(例如,由于客户端中的错误)将导致查询缓冲区中未绑定的内存使用。但是,如果您有非常特殊的需求, # 比如我们的multi/exec请求或类似请求,您可以在这里配置它。 # Client query buffers accumulate new commands. They are limited to a fixed # amount by default in order to avoid that a protocol desynchronization (for # instance due to a bug in the client) will lead to unbound memory usage in # the query buffer. However you can configure it here if you have very special # needs, such us huge multi/exec requests or alike. # # client-query-buffer-limit 1gb # 在Redis协议中,批量请求(即表示单个字符串的元素)通常限制在512MB。但是你可以在这里改变这个限制。 # In the Redis protocol, bulk requests, that are, elements representing single # strings, are normally limited ot 512 mb. However you can change this limit # here. # # proto-max-bulk-len 512mb # Redis调用一个内部函数来执行许多后台任务,比如在超时时关闭客户端的连接,清除从未请求的过期密钥, # 等等。 # 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. # # 并非所有任务都以相同的频率执行,但是Redis会根据指定的“hz”值检查要执行的任务。 # Not all tasks are performed with the same frequency, but Redis checks for # tasks to perform according to the specified "hz" value. # # 默认情况下“hz”设置为10。当Redis空闲时,提高该值将使用更多的CPU, # 但同时会使Redis在多个键同时过期时更具响应性,超时处理可能会更精确。 # 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. # # 范围在1到500之间,但是值超过100通常不是一个好主意。大多数用户应该使用默认值10, # 并且仅在需要非常低延迟的环境中才将其提高到100。 # 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 # 当子级重写AOF文件时,如果启用以下选项,则该文件将每生成32mb的数据进行一次fsync。 # 这对于以更增量的方式将文件提交到磁盘和避免较大的延迟峰值非常有用。 # 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 # Redis LFU逐出(参见maxmemory设置)可以进行调优。但是,最好从默认设置开始, # 在研究如何提高性能以及键LFU如何随时间变化后才进行更改,这可以通过OBJECT FREQ命令进行检查。 # Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good # idea to start with the default settings and only change them after investigating # how to improve the performances and how the keys LFU change over time, which # is possible to inspect via the OBJECT FREQ command. # # Redis LFU实现中有两个可调参数:计数器对数因子和计数器衰减时间。在改变这两个参数之前, # 了解这两个参数的含义是很重要的。 # There are two tunable parameters in the Redis LFU implementation: the # counter logarithm factor and the counter decay time. It is important to # understand what the two parameters mean before changing them. # # LFU计数器每个键只有8位,它的最大值是255,所以Redis使用了对数行为的概率增量。 # 给定旧计数器的值,当访问键时,计数器按以下方式递增: # The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis # uses a probabilistic increment with logarithmic behavior. Given the value # of the old counter, when a key is accessed, the counter is incremented in # this way: # # 提取0到1之间的随机数R。 # 1. A random number R between 0 and 1 is extracted. # # 概率P的计算公式为1/(old_value*lfu_log_factor+1). # 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1). # # 只有当R<P时,计数器才递增。 # 3. The counter is incremented only if R < P. # # 默认的lfu log factor是10。 # 这是一个关于频率计数器如何随着具有不同对数因子的不同访问次数而变化的表: # The default lfu-log-factor is 10. This is a table of how the frequency # counter changes with a different number of accesses with different # logarithmic factors: # # +--------+------------+------------+------------+------------+------------+ # | factor | 100 hits | 1000 hits | 100K hits | 1M hits | 10M hits | # +--------+------------+------------+------------+------------+------------+ # | 0 | 104 | 255 | 255 | 255 | 255 | # +--------+------------+------------+------------+------------+------------+ # | 1 | 18 | 49 | 255 | 255 | 255 | # +--------+------------+------------+------------+------------+------------+ # | 10 | 10 | 18 | 142 | 255 | 255 | # +--------+------------+------------+------------+------------+------------+ # | 100 | 8 | 11 | 49 | 143 | 255 | # +--------+------------+------------+------------+------------+------------+ # # 注:上表是通过运行以下命令获得的: # NOTE: The above table was obtained by running the following commands: # # redis-benchmark -n 1000000 incr foo # redis-cli object freq foo # # 注2:计数器初始值为5,以便给新对象一个累积命中的机会。 # NOTE 2: The counter initial value is 5 in order to give new objects a chance # to accumulate hits. # # #计数器衰减时间是键计数器除以2所必须经过的时间,单位为分钟(如果值小于等于10,则递减)。 # The counter decay time is the time, in minutes, that must elapse in order # for the key counter to be divided by two (or decremented if it has a value # less <= 10). # # lfu衰减时间的默认值为1。特殊值0意味着每次扫描计数器时都会衰减计数器。 # The default value for the lfu-decay-time is 1. A Special value of 0 means to # decay the counter every time it happens to be scanned. # # lfu-log-factor 10 # lfu-decay-time 1 ########################### ACTIVE DEFRAGMENTATION ####################### # # 警告:此功能是实验性的。然而,它甚至在生产中也进行了压力测试, # 并由多名工程师进行了一段时间的手动测试。 # WARNING THIS FEATURE IS EXPERIMENTAL. However it was stress tested # even in production and manually tested by multiple engineers for some # time. # # 什么是活动碎片整理? # What is active defragmentation? # ------------------------------- # # 主动(在线)碎片整理允许Redis服务器压缩内存中数据的小分配和释放之间的空间,从而允许回收内存。 # Active (online) defragmentation allows a Redis server to compact the # spaces left between small allocations and deallocations of data in memory, # thus allowing to reclaim back memory. # # 碎片化是每个分配器(幸运的是Jemalloc)和某些工作负载都会发生的自然过程。 # 通常需要重新启动服务器以降低碎片,或者至少清除所有数据并重新创建。 # 不过,由于OranAgraforRedis4.0实现了这个特性,这个过程可以在服务器运行时以“热”的方式在运行时发生。 # Fragmentation is a natural process that happens with every allocator (but # less so with Jemalloc, fortunately) and certain workloads. Normally a server # restart is needed in order to lower the fragmentation, or at least to flush # away all the data and create it again. However thanks to this feature # implemented by Oran Agra for Redis 4.0 this process can happen at runtime # in an "hot" way, while the server is running. # # 基本上,当碎片超过某个级别(见下面的配置选项)时, # Redis将开始利用某些特定的Jemalloc特性在连续内存区域中创建值的新副本 # (以便了解分配是否导致碎片并将其分配到更好的位置),同时,将发布数据的旧拷贝。 # 这个过程,对所有键进行增量重复,将导致碎片降回正常值。 # Basically when the fragmentation is over a certain level (see the # configuration options below) Redis will start to create new copies of the # values in contiguous memory regions by exploiting certain specific Jemalloc # features (in order to understand if an allocation is causing fragmentation # and to allocate it in a better place), and at the same time, will release the # old copies of the data. This process, repeated incrementally for all the keys # will cause the fragmentation to drop back to normal values. # # 需要了解的重要事项: # Important things to understand: # # 此功能在默认情况下是禁用的, # 并且仅当您编译Redis以使用我们随Redis源代码提供的Jemalloc副本时才起作用。 # 这是Linux版本的默认设置。 # 1. This feature is disabled by default, and only works if you compiled Redis # to use the copy of Jemalloc we ship with the source code of Redis. # This is the default with Linux builds. # # 如果没有碎片问题,就不需要启用此功能 # 2. You never need to enable this feature if you don't have fragmentation # issues. # # 一旦遇到碎片,可以在需要时使用命令“CONFIG SET activedefrag yes”启用此功能。 # 3. Once you experience fragmentation, you can enable this feature when # needed with the command "CONFIG SET activedefrag yes". # # 配置参数能够微调碎片整理过程的行为。如果您不确定它们的含义,那么最好保持默认值不变。 # The configuration parameters are able to fine tune the behavior of the # defragmentation process. If you are not sure about what they mean it is # a good idea to leave the defaults untouched. # 已启用活动碎片整理 # Enabled active defragmentation # activedefrag yes # 启动活动碎片整理的最小碎片浪费量 # Minimum amount of fragmentation waste to start active defrag # active-defrag-ignore-bytes 100mb # 启动活动碎片整理的最小碎片百分比 # Minimum percentage of fragmentation to start active defrag # active-defrag-threshold-lower 10 # 使用最大努力的最大碎片百分比 # Maximum percentage of fragmentation at which we use maximum effort # active-defrag-threshold-upper 100 # 以CPU百分比表示的最小碎片整理工作量 # Minimal effort for defrag in CPU percentage # active-defrag-cycle-min 25 # 以CPU百分比表示的碎片整理最大工作量 # Maximal effort for defrag in CPU percentage # active-defrag-cycle-max 75
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。