Redis 双活复制 [英] Redis active-active replication

查看:116
本文介绍了Redis 双活复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 redis 2.8.3 版.我想构建一个 redis 集群.但是在这个集群中应该有multiple master.这意味着我需要多个具有写访问权限并将能力应用于所有其他节点的节点.

I am using redis version 2.8.3. I want to build a redis cluster. But in this cluster there should be multiple master. This means I need multiple nodes that has write access and applying ability to all other nodes.

我可以用一个主节点和多个从节点构建一个集群.我刚刚配置了 slaves redis.conf 文件并添加了 ;

I could build a cluster with a master and multiple slaves. I just configured slaves redis.conf files and added that ;

slaveof myMasterIp myMasterPort

仅此而已.比我尝试通过 master 将一些内容写入 db.它被复制到所有奴隶,我真的很喜欢它.

Thats all. Than I try to write something into db via master. It is replicated to all slaves and I really like it.

但是当我尝试通过奴隶写作时,它告诉我奴隶没有写作的权利.之后,我只是将 redis.conf 文件中的 slave 的只读状态设置为 false.因此,我可以将一些内容写入 db.但我意识到,它没有复制到我的主复制,所以它也没有复制到所有其他从属.

But when I try to write via a slave, it told me that slaves have no right to write. After that I just set read-only status of slave in redis.conf file to false. Hence, I could write something into db. But I realize that, it is not replicated to my master replication so it is not replicated to all other slave neigther.

这意味着我无法构建主动-主动集群.

This means I could'not build an active-active cluster.

我试图找出redis是否具有双活集群能力.但我找不到确切的答案.

I tried to find something whether redis has active-active cluster capability. But I could not find exact answer about it.

可以用redis搭建双活集群吗?如果是,我该怎么做?

Is it available to build active-active cluster with redis? If it is, How can I do it ?

谢谢!

推荐答案

Redis v2.8.3 不支持多主设置.然而,真正的问题是你为什么要设置一个?换句话说,您想解决什么挑战/问题?

Redis v2.8.3 does not support multi-master setups. The real question, however, is why do you want to set one up? Put differently, what challenge/problem are you trying to solve?

看起来您要解决的挑战是如何通过消除网络读取来减少网络负载(更多内容见下文).由于 Redis 不是多主(还),唯一的方法是设置每个应用服务器与一个主从(到另一个主) - 即总共 4Redis 实例(以及两倍的 RAM).

It looks like the challenge you're trying to solve is how to reduce the network load (more on that below) by eliminating over-the-net reads. Since Redis isn't multi-master (yet), the only way to do it is by setting up each app server with a master and a slave (to the other master) - i.e. grand total of 4 Redis instances (and twice the RAM).

最简单的情况是,每个应用只更新数据库键的一个互斥子集.在那种情况下,这种设置实际上可能是有益的(至少在短期内).但是,如果两个应用程序都可以触摸所有键,或者即使只有一个键被共享"用于应用程序之间的写入,那么您需要将锁定/冲突解决/等......逻辑烘焙到您的应用程序中以整合本地主和奴隶的差异(这可能有点矫枉过正).然而,无论哪种情况,最终都会有太多(即超过 1 个)Redises,这至少意味着需要更多的管理工作.

The simple scenario is when each app updates only a mutually-exclusive subset of the database's keys. In that scenario this kind of setup may actually be beneficial (at least in the short term). If, however, both apps can touch all keys or if even just one key is "shared" for writes between the apps, then you'll need to bake locking/conflict resolution/etc... logic into your apps to consolidate local master and slave differences (and that may be a bit of an overkill). In either case, however, you'll end up with too many (i.e. more than 1) Redises, which means more admin effort at the very least.

另请注意,通过将应用程序和数据库托管在同一台服务器上,您将自己设置为几乎确定的可扩展性失败.当您的应用程序或 Redis 需要更多计算资源时会发生什么?您将如何添加另一个应用服务器?

Also note that by colocating app and database on the same server you're setting yourself for near-certain scalability failure. What will happen when you need more compute resources for your apps or Redis? How will you add yet another app server to the mix?

这让我回到了您试图解决的实际问题 - 网络负载.为什么这是一个问题?您的应用程序是吞吐量如此之大,还是网络如此之薄以至于您愿意付出如此大的努力?或者延迟是您想要解决的问题?无论如何,我建议您考虑采用经过时间验证的设计,即将 Redis 从应用程序中分离出来,并将其放在自己的资源上.确实,网络会打你的脸,你必须解决/使用它(这是其他人所做的).另一方面,您将拥有更大的灵活性和对更简单的设置的控制权,在我看来,这是一个巨大的收获.

Which brings me back to the actual problem you are trying to solve - network load. Why exactly is that an issue? Are your apps so throughput-heavy or is the network so thin that you are willing to go to such lengths? Or maybe latency is the issue that you want to resolve? Be the case as it may be, I recommended that you consider a time-proven design instead, namely separating Redis from the apps and putting it on its own resources. True, network will hit you in the face and you'll have to work around/with it (which is what everybody else does). On the other hand, you'll have more flexibility and control over your much simpler setup and that, in my book, is a huge gain.

这篇关于Redis 双活复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆