容器部署 redis 哨兵集群 【问题笔记】

目录

1.哨兵模式 (sentinel) 启动时报错:Can`t resolve instance hostnames

2.哨兵模式下 master 节点崩掉后无法切换从节点为master节点


1.哨兵模式 (sentinel) 启动时报错:Can`t resolve instance hostnames

报错原因分析:

只有 6.2 以上版本的 sentinel 才能解析主机名,但默认不启用。

解决方案:

sentinel.conf 配置文件添加:

sentinel resolve-hostnames yes
sentinel announce-hostname yes

 

参考:使用docker启动redis sentinel 无法使用服务名访问redis_docker 服务名访问_小光头发多的博客-CSDN博客

2.哨兵模式下 master 节点崩掉后无法切换从节点为master节点

原因分析:

容器部署时,网络不通,无法获取实例地址(显示的是两个错误的地址)

 参考:Redis master is getting wrong ip, port of slave in kubernetes redis-sentinel - Stack Overflow

 解决方案:

参考:

Master detects wrong IP for the slave nodes · Issue #248 · docker-library/redis · GitHub

in a K8s deployment, Sentinel Can't update the IP of the old master when the old master get back online again with different IP · Issue #8300 · redis/redis · GitHub

Redis-Sentinel 如何开启域名解析 - 掘金

① 在 sentinel.conf 中 开启 resolve-hostnames and announce-hostnames

sentinel resolve-hostnames yes
sentinel announce-hostnames yes

② 在每个实例配置文件(redis.conf /redis_slave.conf)加上 replica-announce-ip 和 replica-announce-port

replica announce-ip <ip>
replica announce-port <port>

参考:Redis-Sentinel 如何开启域名解析 - 掘金

redis 官网:High availability with Redis Sentinel | Redis

猜你喜欢

转载自blog.csdn.net/qq_42183414/article/details/130847034
今日推荐