[英]Cache a redis cluster locally
I have a scenario where we want to use redis
, but I am not sure how to go about setting it up. 我有一个要使用
redis
的场景,但是我不确定如何进行设置。 Here is what we want to achieve eventually: 这是我们最终要实现的目标:
A redundant central redis
cluster where all the writes will occur with servers in two aws
regions. 一个冗余的中央
redis
群集,其中所有写入将在两个aws
区域中的服务器上进行。
Local redis
caches on servers which will hold a replica of the complete central cluster. 服务器上的本地
redis
缓存将保存整个中央集群的副本。
The reason for this is that we have many servers which need read access only, and we want them to be independent even in case of an outage (where the server cannot reach the main cluster). 这样做的原因是,我们有许多只需要读访问权限的服务器,即使在发生故障(服务器无法到达主群集)的情况下,我们也希望它们是独立的。
I know there might be a "stale data" issue withing the caches, but we can tolerate that as long as we get eventual consistency. 我知道缓存可能存在“过时的数据”问题,但是只要我们能达到最终的一致性,我们就可以忍受。
What is the correct way to achieve something like that using redis
? 使用
redis
实现类似目标的正确方法是什么?
Thanks! 谢谢!
You need the Redis Replication (Master-Slave) Architecture . 您需要Redis复制(主从)体系结构 。
Redis replication is a very simple to use and configure master-slave replication that allows slave Redis servers to be exact copies of master servers. Redis复制使用和配置主从复制非常简单,它允许从Redis服务器成为主服务器的精确副本。 The following are some very important facts about Redis replication:
以下是有关Redis复制的一些非常重要的事实:
Go through the Steps : How to Configure Redis Replication . 完成以下步骤: 如何配置Redis复制 。
So I decided to go with redis-sentinel
. 因此,我决定使用
redis-sentinel
。
Using a redis-sentinel
I can set the slave-priority
on the cache servers to 0, which will prevent them from becoming masters. 使用
redis-sentinel
我可以将缓存服务器上的slave-priority
设置为0,这将阻止它们成为主服务器。
I will have one master set up, and a few "backup masters" which will actually be slaves with slave-priority
set to a value which is not 0, which will allow them to take over once the master goes down. 我将设置一个主服务器,以及几个“备份主服务器”,它们实际上将是从属服务器,其
slave-priority
设置为不为0的值,一旦主服务器发生故障,它们将接管他们。
The sentinel will monitor the master, and once the master goes down it will promote one of the "backup masters" and promote it to be the new master. 哨兵将监视主服务器,一旦主服务器崩溃,它将升级“备份主服务器”之一并将其升级为新的主服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.