Container Deployment Redis Sentinel Cluster [Problem Notes]

Table of contents

1. An error is reported when the sentinel starts: Can`t resolve instance hostnames

2. In sentinel mode, the slave node cannot be switched to the master node after the master node collapses


1. An error is reported when the sentinel starts: Can`t resolve instance hostnames

Analysis of the cause of the error:

Only sentinel versions above 6.2 can resolve hostnames, but it is not enabled by default.

solution:

The sentinel.conf configuration file adds:

sentinel resolve-hostnames yes
sentinel announce-hostname yes

 

Reference: Use docker to start redis sentinel cannot use service name to access redis_docker service name access - small bald hair blog - CSDN blog

2. In sentinel mode, the slave node cannot be switched to the master node after the master node collapses

Cause Analysis:

When the container is deployed, the network is disconnected and the instance address cannot be obtained (two wrong addresses are displayed)

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

 solution:

 

reference:

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

How does Redis-Sentinel enable domain name resolution - Programmer Sought

① Enable resolve-hostnames and announce-hostnames in sentinel.conf

sentinel resolve-hostnames yes
sentinel announce-hostnames yes

② Add replica-announce-ip and replica-announce-port to each instance configuration file (redis.conf /redis_slave.conf)

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

Reference: How Redis-Sentinel enables domain name resolution - Nuggets

redis 官网:High availability with Redis Sentinel | Redis

Guess you like

Origin blog.csdn.net/qq_42183414/article/details/130847034