Reputation: 698
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 ?
Upvotes: 3
Views: 7128
Reputation: 17751
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.
Upvotes: 1