简体   繁体   English

Redis群集配置

[英]Redis Cluster Configuration

I am using spring redisTemplate(jedis, 2.0.0) with redis-server(2.9.50) . 我使用spring redisTemplate(jedis, 2.0.0)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)? 什么是创建主/从Redis集群的正确方法(现在我只安装了redis-server而没有配置更改)?

how to connect jedis with redis cluster ? 如何将jedisredis集群连接?

what should I use to replicate data between redis clusters nodes ? 我应该用什么来在redis集群节点之间复制数据?

I think you need to upgrade your version of jedis to get the cluster support. 我认为您需要升级您的jedis版本才能获得群集支持。 From the README , the usage looks straight-forward: README ,用法看起来很简单:

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. 使用create-cluster脚本创建Redis群集部分可以让您快速启动并运行,并且可以从那里进行调整和更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM