文章目录
相关文章传送门
Redis Sentinel 集群部署方案
概述
Redis集群可以在一组Redis节点之间实现高可用性和sharding,在集群中会有1个master和多个slave节点。当master节点失效时,应选举出一个slave节点作为新的master。然而Redis本身(包括它的很多客户端)没有实现自动故障发现并进行主备切换的能力,需要外部的监控方案来实现自动故障恢复,Redis集群如下图所示。
Redis Sentinel 核心配置
参考
# Example sentinel.conf
# *** IMPORTANT ***
#
# By default Sentinel will not be reachable from interfaces different than
# localhost, either use the 'bind' directive to bind to a list of network
# interfaces, or disable protected mode with "protected-mode no" by
# adding it to this configuration file.
# 默认情况下,从不同于的接口将无法访问标记
# 本地主机,可以使用'bind'指令绑定到网络列表
# 接口,或禁用“受保护模式no”的受保护模式
# 将其添加到此配置文件中。
#
# Before doing that MAKE SURE the instance is protected from the outside
# world via firewalling or other means.
# 在此之前,请确保实例受外部保护
# 世界通过防火墙或其他方式
#
# For example you may use one of the following:
# 例如,你可以使用以下其中一种:
#
# bind 127.0.0.1 192.168.1.1
#
# protected-mode no
# port <sentinel-port>
# The port that this sentinel instance will run on
# 此标记实例将在其上运行的端口
port 26379
# sentinel announce-ip <ip>
# sentinel announce-port <port>
#
# The above two configuration directives are useful in environments where,
# because of NAT, Sentinel is reachable from outside via a non-local address.
# 以上两个配置指令在以下环境中非常有用:
# 由于NAT的原因,哨兵可以从外部通过一个非本地地址到达。
#
# When announce-ip is provided, the Sentinel will claim the specified IP address
# in HELLO messages used to gossip its presence, instead of auto-detecting the
# local address as it usually does.
# 当提供了通知IP时,标记将声明指定的IP地址
# 在HELLO消息中用来八卦它的存在,而不是自动检测
# 本地地址通常是这样的。
#
# Similarly when announce-port is provided and is valid and non-zero, Sentinel
# will announce the specified TCP port.
# 类似地,当提供了通知端口,且该端口有效且非0时,进行标记
# 将宣布指定的TCP端口。
#
# The two options don't need to be used together, if only announce-ip is
# provided, the Sentinel will announce the specified IP and the server port
# as specified by the "port" option. If only announce-port is provided, the
# Sentinel will announce the auto-detected local IP and the specified port.
# 如果只使用announcement -ip,则不需要同时使用这两个选项
# 提供,哨兵将宣布指定的IP和服务器端口
# 由“端口”选项指定。如果只提供通知端口,则
# Sentinel会通知自动侦测到的本地IP和指定的端口。
#
# Example:例子
#
# sentinel announce-ip 1.2.3.4
# dir <working-directory>
# Every long running process should have a well-defined working directory.
# For Redis Sentinel to chdir to /tmp at startup is the simplest thing
# for the process to don't interfere with administrative tasks such as
# unmounting filesystems.
dir /tmp
# sentinel monitor <master-name> <ip> <redis-port> <quorum&g