2 Node Redis HA

I have two nodes which I want to run as servers in active-active mode and also have HA capability ie 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.


Ok, partial solution with SLAVEOF:

You can manually promote slave to master by running:

SLAVEOF NO ONE

You can manually transition master to slave by running:

SLAVEOF <HOST> <port>

Clustering should be disabled.


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.


我建议至少有3个节点使用Sentinel安装程序,以便在当前主节点发生故障时启用八卦/仲裁来将从站自动升级为主节点。

链接地址: http://www.djcxy.com/p/37596.html

上一篇: 点云XYZ格式规范

下一篇: 2节点Redis HA