Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2 Node Redis HA

I have two nodes which I want to run as servers in active-active mode and also have HA capability i.e if one is down, the other one should start receiving all the requests but while both are up, both should be taking all the requests. Now since Redis doesn't allow active-active mode for the same hash set and I don't have option to run Sentinel as I can't have a third node, my idea is to run the two nodes in replication and myself decide if master node is down and promote the slave to master. Are there any issues with this? When the original master comes back up, is there a way to configure it as slave?

Does this sound like a good idea? I am open to suggestions other than Redis.

like image 874
BigBrother323 Avatar asked Dec 22 '16 07:12

BigBrother323


People also ask

Is Redis high availability?

Memorystore for Redis provides high availability by replicating a primary Redis node to one or more replica nodes. Changes made to the data on the primary node are copied to the replica using the Redis asynchronous replication protocol.

What is ha in Redis?

Redis Enterprise allows you to have a complete high availability (HA) system with only two replicas. Your tiebreaker is determined at the node level by using an uneven number of nodes in a cluster.

How many nodes does a Redis cluster have?

The node or shard limit can be increased to a maximum of 500 per cluster if the Redis engine version is 5.0. 6 or higher. For example, you can choose to configure a 500 node cluster that ranges between 83 shards (one primary and 5 replicas per shard) and 500 shards (single primary and no replicas).

How does Redis HA work?

Essentially, for Redis High Availability, Redis Sentinel regularly checks the Slave and the Master instances within the cluster. This way, in case a failure is detected in the Master node, the slaves must reach a quorum. As soon as they do, the Sentinel then picks a Slave server and then promotes it to Master.


1 Answers

Generally running two node is never a good idea because it is bound to have split brain problem: When the network between the two node is down for a moment or two, the two node will inevitably think each other is offline and will promote/keep itself to be master and start accepting requests from other services. Then the split brain happens.

And if you are OK with this possible situation, then you can look into setup a master-slave with help of a script file and a HA service like pacemaker or keepalived.

Typically you have to tell the cluster manager through a predefined rule that when two machine rejoins under split brain condition, which one is your preferred master.

When a master is elected, execute the script and basically it execute slaveof no one on itself and execute slaveof <new-master-ip> <port> on the other node.

You could go one step further in your script file and try to merge the two data sets together but whether that's achievable or not is entirely down to how you have organized your data in Redis and how long you are prepared to wait for to have all the data in sync.

I have done this way myself before through pacemaker+corosync.

like image 91
Redisson_RuiGu Avatar answered Sep 25 '22 23:09

Redisson_RuiGu