redis - 带有哨兵的 Redis 在脑裂后的表现如何?

标签 redis nosql quorum splitbrain

问题是关于 Redis 服务器和哨兵配置的。

有两个子网,我想总共有 4 个 redis 服务器,每个子网 2 个。由于可能存在连接问题,我想配置哨兵以允许大脑 split 以实现高可用性。

因此,当发生连接问题时,会出现两个独立工作一段时间的 Redis 设置。

现在的问题是子网连接恢复后会发生什么。哨兵会检测脑裂和两个高手?接下来他们将只选举主人,第二个将被降级为奴隶?来自幸存主控的数据将被推送到降级主控,他将需要删除在连接问题期间获得的所有数据差异?

我可以配置一些东西以便合并数据吗?

最佳答案

redis 中有两种处理 HA 的方法 - sentinelredis cluster .

哨兵

If a master is not working as expected, Sentinel can start a failover process where a slave is promoted to master, the other additional slaves are reconfigured to use the new master, and the applications using the Redis server informed about the new address to use when connecting

问:由于可能存在连接问题,我想配置哨兵以允许大脑 split 以实现高可用性

这是使用 sentinel 的反模式。这是一个类似的例子,在文档中解释了偶数个节点

Example 1: just two Sentinels, DON'T DO THIS

In the above configuration we created two masters (assuming S2 could failover without authorization) in a perfectly symmetrical way. Clients may write indefinitely to both sides, and there is no way to understand when the partition heals what configuration is the right one, in order to prevent a permanent split brain condition. So please deploy at least three Sentinels in three different boxes always.

问:现在的问题是子网连接恢复后会发生什么。哨兵会检测到大脑 split 和两个主人?

This data will be lost forever since when the partition will heal, the master will be reconfigured as a slave of the new master, discarding its data set.

问:来自幸存主机的数据将被推送到降级主机,他需要删除在连接问题期间获得的所有数据差异?

问:我可以配置一些东西以便合并数据吗? 你不能,redis 永远不会合并任何东西

Redis集群

这是什么beast为了?

The ability to automatically split your dataset among multiple nodes. The ability to continue operations when a subset of the nodes are experiencing failures or are unable to communicate with the rest of the cluster.

所以它基本上是一个多作者解决方案。但是不支持合并操作either

Redis Cluster design avoids conflicting versions of the same key-value pair in multiple nodes as in the case of the Redis data model this is not always desirable. Values in Redis are often very large; it is common to see lists or sorted sets with millions of elements. Also data types are semantically complex. Transferring and merging these kind of values can be a major bottleneck and/or may require the non-trivial involvement of application-side logic, additional memory to store meta-data, and so forth.

回到你的场景

引自here

Fundamental things to know about Sentinel before deploying

You need at least three Sentinel instances for a robust deployment. The three Sentinel instances should be placed into computers or virtual machines that are believed to fail in an independent way. So for example different physical servers or Virtual Machines executed on different availability zones.

请注意,您也可以在客户端机器上放置哨兵 - 这种方法在 redis 演示中大量使用 https://redis.io/topics/sentinel

您也可以使用集群解决方案,但它更难配置 + 它对多键操作有一些限制,您仍然需要提供 majority节点的数量,以防其中一个子网出现故障以具有某种 HA

关于redis - 带有哨兵的 Redis 在脑裂后的表现如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48629944/

相关文章:

build - Cloudbees 上的 Redis 版本已过时?

ruby-on-rails - Redis 中缓存的最佳 expire_in 值

redis - 当前用于生产环境的 redis HA/cluster 实现

database - 选择带有允许过滤的低基数列会抛出错误 : No secondary indexes on the restricted columns support the provided operators

java - 在 Java 中实现数据库管理层 (neo4j) 的指南

amazon-web-services - apt-get 在 docker-container 上超时

django - django-redis-cache 和 django-redis 之间用于使用 Django 进行 redis 缓存的区别?

apache-zookeeper - Zookeeper 法定人数和非法定人数

blockchain - 在客户端应用程序中使用 web3 库安全吗?

nosql - 如何为我的用例选择正确的键值对存储?