简体   繁体   English

如何测试Redis集群

[英]how to test redis cluster

I have a Redis cluster with 3 masters. 我有一个具有3个主服务器的Redis集群。 I am not interested in data persistence since this is a caching solution. 我对数据持久性不感兴趣,因为这是一个缓存解决方案。 I am running v3.2 on Windows. 我在Windows上运行v3.2。 When I stop one of the servers manually to see if I can still access the db, I get 'CLUSTERDOWN The cluster is down error'. 当我手动停止其中一台服务器以查看是否仍然可以访问数据库时,出现“ CLUSTERDOWN群集已关闭错误”。 And even to do that, I have to connect to one of the instances that is still working. 甚至要做到这一点,我必须连接到仍在工作的实例之一。 I don't see how this is a solution for high availability. 我看不出这是如何实现高可用性的解决方案。 I hope that I am missing something. 我希望我缺少一些东西。 Any ideas why I can't access the cluster when one of the nodes is down? 有什么想法为什么当一个节点发生故障时我无法访问群集? Thank you. 谢谢。

Cluster create command:ruby.exe redis-trib.rb create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 群集创建命令:ruby.exe redis-trib.rb创建127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002

As you said that you're using 3 master nodes within Redis Cluster, so it is clearly visible that if one of node will down then you'll get CLUSTERDOWN errors. 正如您说的那样,您在Redis Cluster中使用了3个主节点,因此可以清楚地看到,如果其中一个节点将关闭, CLUSTERDOWN出现CLUSTERDOWN错误。

To avoid these type of errors and get high availability, its better to have slaves attached to those of your master nodes(as shown in official Redis Cluster tutorial here ). 为了避免这些类型的错误,并获得高可用性,它能够更好地拥有奴隶连接到那些你的主节点(如图官方的Redis集群教程这里 )。

There's a reason to have slave attached with your master to get higher availability. 将主服务器与从属服务器连接以获得更高的可用性是有原因的。 For that you can read these lines mentioned in above Redis cluster tutorial link. 为此,您可以阅读上述Redis集群教程链接中提到的这些行。

There are 16384 hash slots in Redis Cluster, and to compute what is the hash slot of a given key, we simply take the CRC16 of the key modulo 16384. Redis集群中有16384个哈希槽,要计算给定密钥的哈希槽,我们只需对密钥的CRC16取模16384。

Every node in a Redis Cluster is responsible for a subset of the hash slots, so for example you have a cluster with 3 nodes, where: Redis群集中的每个节点都负责哈希槽的一个子集, 因此,例如,您有一个包含3个节点的群集,其中:

1) Node A contains hash slots from 0 to 5500. 1)节点A包含从0到5500的哈希槽。

2) Node B contains hash slots from 5501 to 11000. 2)节点B包含从5501到11000的哈希槽。

3) Node C contains hash slots from 11001 to 16383. 3)节点C包含从11001到16383的哈希槽。

So whenever you used to SET a Key in Redis cluster, it calculates its hash slot value for that key and save key accordingly in one of node. 因此,每当您用于在Redis集群中SET密钥时,它都会为该密钥计算其哈希槽值,并相应地将密钥保存在节点之一中。 This is the reason it is mandatory to have all of nodes(At least master or its one slave) to be active in Redis Cluster. 这就是在Redis Cluster中强制所有节点(至少主节点或一个从节点)处于活动状态的原因。

Rest if you'll attach at least 1 slave with every master node into your Redis Cluster, you'll get better Redis Cluster availability. 如果将每个主节点上的至少一个从属节点附加到Redis群集中,您将获得更好的Redis群集可用性。 After attaching slaves with your master node, you can test your setup for higher availability by closing any of master node manually. 将从属节点附加到主节点后,您可以通过手动关闭任何主节点来测试设置的可用性。

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

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