Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis Cluster Configuration

I am using spring redisTemplate(jedis, 2.0.0) with redis-server(2.9.50). It's working perfectly for the single instance but I want to create a cluster master-slave environment with two different instances in which replication and failover happen automatically (over configuration).

Please answer the following queries

what's the proper way to create master/slave Redis cluster(right now I've only redis-server installed with no config change)?

how to connect jedis with redis cluster ?

what should I use to replicate data between redis clusters nodes ?

like image 718
Himanshu Arora Avatar asked Jun 30 '26 15:06

Himanshu Arora


1 Answers

I think you need to upgrade your version of jedis to get the cluster support. From the README, the usage looks straight-forward:

Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
//Jedis Cluster will attempt to discover cluster nodes automatically
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7379));
JedisCluster jc = new JedisCluster(jedisClusterNodes);
jc.set("foo", "bar");
String value = jc.get("foo");

In terms of setup, there's a lot of considerations, you should consult this tutorial for basic setup and considerations. The section Creating a Redis Cluster using the create-cluster script will get you up and running pretty quickly and you can make tweaks & changes from there.

like image 170
leeor Avatar answered Jul 02 '26 05:07

leeor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!