Redis cluster need at least 3 master nodes

1,852 views
Skip to first unread message

Yuantao Yin

unread,
Aug 3, 2016, 5:33:43 PM8/3/16
to Redis DB
Hi All,

I want to use Redis to store user session. I will use Redis Cluster and Jedis to support HA. Redis cluster guide say it need at least 3 master nodes (3 master +  3 slaves). In the production, if I don't have 6 servers(vm) available, but only have two now, can I install 3 master node on one and 3 slaves on the other?


Thanks,
Yuantao

andyh

unread,
Aug 4, 2016, 4:14:33 AM8/4/16
to redi...@googlegroups.com
Of course you can. But if the master vm goes down, you won't have a functional Redis Cluster. Because in order to make Cluster work you need majority of masters to be alive. Therefore, masters on one vm and slaves on the other is not a right way to deploy them. In reality, you will find you won't create such a topology because redis-trib.rb will try to allocate masters to different nodes. In your case, you will end up two masters on one node and one master in another. As a result, when a node goes down, you will have 50% probability to lose the whole cluster, again, you don't want that.

So for a proper cluster setup, you need at least 3 independent nodes. This is the same case with Redis Sentinel. 

If you are limited by the number of nodes you can have and you just want HA, you should try setting up simple master-slave pair with the two nodes and do the failover at the client side. 

Thanks,
Andy


--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--
andyh
Andy Huang (Huangkejun)

Yuantao Yin

unread,
Aug 5, 2016, 3:54:43 PM8/5/16
to Redis DB
Thank you! I didn't realize redis-trib.rb will try to allocate masters to different nodes since I'm testing it with localhost. I think I only can go master-slave pair and do fail over in the client. 

The problem now is all the HA topic I saw so far are about Sentinel or Redis Cluster. Do you know any existing client example for single master failover to slave, such as Jedis?



Thanks,
Yuantao

andyh

unread,
Aug 6, 2016, 11:19:32 AM8/6/16
to redi...@googlegroups.com
I don't know about Jedis and I doubt it can actually provide the feature. 

if you do at the client side, inevitably you need help from configuration service like ZooKeeper/Consul/etcd to do the failover and later tell all the applications which is the new master to connect to. 

In my opinion, in your case, you should try to get another VM and enjoy the features provided by Sentinel instead of developing your own(It's not that easy to get it right at the beginning). 

Thanks,
Andy

To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.

To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Yuantao Yin

unread,
Aug 6, 2016, 11:05:30 PM8/6/16
to Redis DB
Our application certainly don't need large distributed caching so I try to avoid complexity by using Zookeeper/Sentinel. And I know Sentinel also require at least 3 nodes. My plan is have app and redis master install on one server and another one with app and redis slave. Maybe I just use app server's LB.

As your suggestion I will need 
app+redis master+sentinel1
app2+redis slave+sentinel2
redis slave+sentinel3
Am I right?


Thanks,
Yuantao

Tuco

unread,
Aug 7, 2016, 12:10:20 AM8/7/16
to Redis DB
I think you can create a cluster using redis trib and failover will work well..

Just make sure to not have master and its slave on a single machine.

Then, when the master VM goes down, all slaves will automatically become masters, so the cluster will work perfectly.

Eg if you have
Machine 1: Master1, Master2, Slave3
Machine 2: Slave1, Slave2, Master 3.

If machine 1 goes down, you will have
Machine1: Nothing
Machine2: Master1, Master2, Master3

andyh

unread,
Aug 7, 2016, 12:30:47 AM8/7/16
to redi...@googlegroups.com
Mostly in terms of Redis and Sentinel setup. But i won't put my application and database on the same machine...


To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.

To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages