阿里云ECS部署Redis主备哨兵集群遇到的问题

1、部署html

详细部署步骤:http://www.javashuo.com/article/p-rccatnah-ca.html网络

Redis5.0版本须要注意的参数配置:http://www.javashuo.com/article/p-xtzmupsm-bp.htmlide

 

2、遇到的问题阿里云

一、bind公网IP地址时,会出现异常:【Cannot assign requested address】spa

  首先理解bind的含义:http://www.javashuo.com/article/p-vtjgxqpc-cc.html.net

  缘由:这里没法bind公网IP地址,是由于ECS的本地IP是经过NAT技术转换成了公网IP,即公网IP不是ECS任意一个网卡上的IPcode

  解决方案:bind 0.0.0.0,这样不论阿里云私网仍是公网都可以访问server

二、SpringBoot配置Redis主备哨兵集群后,没法链接htm

  缘由:ECS实例既绑定了私网IP地址,也绑定了公网IP地址,哨兵会将监控的Redis实例IP地址收集管理起来,设置bind 0.0.0.0后,使得哨兵会收集这两个IP地址,而链接时使用的是私网IP地址,故没法链接blog

  解决方案:修改哨兵配置文件sentinel.conf,【sentinel announce-ip 哨兵所在的公网IP】

  announce-ip配置项的官方解释以下:

# 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.
#
# 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.
#
# Similarly when announce-port is provided and is valid and non-zero, Sentinel
# will announce the specified TCP port.
#
# 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.

  大体意思是:考虑到NAT网络的存在,设置非本地IP后,哨兵能够正常地被外部访问

  同时,哨兵启动后,经过观察配置文件sentinel.conf,发现已不会收集Redis实例的私网IP

  最后SpringBoot能够正常链接Redis主备哨兵集群

 

注:以上场景为一主三备两哨兵,一主一备一哨兵在同一个ECS实例上,两备一哨兵在另外一个ECS实例上,这两个ECS实例在同一个区域,属于同一个私有网段,且均绑定了公网IP

相关文章
相关标签/搜索