Supporting Slave of Slave Replication with Redis Sentinel?
Asked Answered
N

1

9

We have two datacenters, each with two redis instances. Generally they are replicated as chain.

NY1 (Master) --> NY2 (Slave) --> CO1 (Slave) --> CO2 (Slave)

NY is New York and CO is Colorado, our backup datacenter. In order to save bandwidth over the WAN, we don't want CO1 and CO2 connected to NY1. Rather we want a chain configuration, where there is only one slave directly to the master, and the others are all "slaves of slaves".

Can this sort of replication layout be maintained using Sentinel? Or do all slaves have to be a slave of the master, and not a slave of a slave?

Northward answered 8/12, 2017 at 15:31 Comment(0)
W
1

Currently this type of setup isn't possible with Sentinel because Sentinel rewrites the configurations of all monitored Redis systems.

For example, if you set up a system as you described and have sentinel monitoring all of the hosts, if the master goes down and forces a failover, each of the Redis hosts will be re-configured. One of the replicas (any of them) will become the new master, and the others will become replicas of the new master. When the old master comes back online, it will be re-configured to be a replica of the new master.

However, in general you can get Redis to work the way you want. You can have as many replicas of a replica as you need by setting the replicaof config value to a replica.

Personally, I would still use Sentinel to monitor the master and the "prime" replicas (those that replicate from the master itself). This could result in one of the prime replicas becoming a new master, so I would enable the notification option. This tells sentinel to call a script whenever a failover happens. In that script you can send an email, hit a Slack webhook, or whatever else you want to do with it. When I get it, I'd manually reconfigure the hosts back into the format I want, but with the new master. It'd be a pain to do it this way but I'd still get automatic failover of the master and prime replicas so my apps will continue working.

Weald answered 25/1, 2021 at 18:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.