1

I'm building out tools to help manage/test our redis configuration. I have 5 redis instances (1 master / 4 replicas). 3 of them have sentinel running on them. My redis options only defines the 3 sentinel hosts/ports. When connection is requested it builds up the ConnectionMultiplexer. At that point it looks like sentinel negotiated what the actual redis server hosts/ports are and applied those in the Configuration string. If I run the GetEndpoints method on the connectionMultiplexer I get the 5 redis hosts/ports and not any sentinel hosts/ports.

I'm sure this is by design as sentinel is telling the connectionMultiplexer what actual instances are available to connect to. I could be just not understanding how the IServer.SentinelFailoverAsync works. Should the instance of IServer be a sentinel server or a regular redis server? The only parameter the method takes too is the serviceName. Am I supposed to tell it what server I want it to failover to or is Sentinel just negotiating what it thinks is the next best master. I'm just not finding a lot of documentation on how it works.

Back to the code. If I specify the endpoint object as a sentinel server host/port and do:

var server = connection.GetServer(endpoint);

it throws an exception because as I said before sentinel re-negotiated the connectionMultiplexer to have my redis server instances as the endpoints and dropped the sentinel hosts. I was attempting to:

await server.SentinelFailoverAsync(sentinelServiceName);

Any pointers would be appreciated.

gilm0079
  • 595
  • 1
  • 4
  • 18

0 Answers0