3

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 ?

Vinay Prajapati
  • 7,199
  • 9
  • 45
  • 86
Himanshu Arora
  • 688
  • 1
  • 9
  • 20
  • you may want to split this question up into multiple questions, its very broad right now – leeor Feb 11 '16 at 16:21

1 Answers1

1

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.

leeor
  • 17,041
  • 6
  • 34
  • 60