#redis提供了可以让master停止写入的方式,如果配置了min-slaves-to-write,健康的slave的个数小于N,mater就禁止写入。master最少得有多少个健康的slave存活才能执行写命令。这个配置虽然不能保证N个slave都一定能接收到master的写操作,但是能避免没有足够健康的slave的时候,master不能写入来避免数据丢失。设置为0是关闭该功能。
# min-slaves-to-write 3
# 延迟小于min-slaves-max-lag秒的slave才认为是健康的slave
# min-slaves-max-lag 10
#设置1或另一个设置为0禁用这个特性。
# Setting one or the other to 0 disables the feature.
#
# By default min-slaves-to-write is set to 0 (feature disabled) and
# min-slaves-max-lag is set to 10. 默认配置
# 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 masteer.
# Redis master能够以不同的方式列出所连接slave的地址和端口。 例如,“INFO replication”部分提供此信息,除了其他工具之外,Redis Sentinel还使用该信息来发现slave实例。 此信息可用的另一个地方在masterser的“ROLE”命令的输出中。
#
# The listed IP and address normally reported by a slave is obtained
# in the following way:
#通常由slave报告的列出的IP和地址,通过以下方式获得:
# IP: The address is auto detected by checking the peer address
# of the socket used by the slave to connect with the master.
#IP:通过检查slave与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.
#端口:端口在复制握手期间由slavet通信,并且通常是slave正在使用列出连接的端口。
# 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.
#然而,当使用端口转发或网络地址转换(NAT)时,slave实际上可以通过(不同的IP和端口对)来到达。 slave可以使用以下两个选项,以便向master报告一组特定的IP和端口,以便INFO和ROLE将报告这些值。
# There is no need to use both the options if you need to override just
# the port or the IP address. 如果你需要仅覆盖端口或IP地址,则没必要使用这两个选项。
#
# slave-announce-ip 5.5.5.5
# slave-announce-port 1234
下面关于Redis的文章您也可能喜欢,不妨参考下:
Ubuntu 14.04下Redis安装及简单测试
Redis主从复制基本配置
CentOS 7下Redis的安装与配置
Ubuntu 16.04环境中安装PHP7.0 Redis扩展
CentOS 7.0 安装Redis 3.2.1详细过程和使用常见问题