简体   繁体   English

Redis 主从配置

[英]Redis Master Slave Configuration

I am trying to set up a Master-Slave Redis setup with 1 Master and 2 Slaves and 3 Sentinel nodes.我正在尝试使用 1 个主节点和 2 个从节点以及 3 个 Sentinel 节点来设置主从 Redis 设置。 Could anyone clarify the below questions?有人可以澄清以下问题吗?

  1. What is the difference between replicaof and slaveof properties? replicaof 和 slaveof 属性有什么区别? Some articles that referred uses either of the above properties when setting up the slave node.一些引用的文章在设置从节点时使用了上述任一属性。 So I am confused about which should be used in slave nodes.所以我很困惑应该在从节点中使用哪个。

  2. By default Redis uses asynchronous replication to replicate its data to Slave nodes.默认情况下,Redis 使用异步复制将其数据复制到 Slave 节点。 Is there a property to change this behaviour ie to synchronous replication?是否有更改此行为的属性,即同步复制? My application is read-intensive and the number of writes is less.我的应用程序是读取密集型的,写入次数较少。 So thinking if I can make writes as synchronous(Master to all online Slave) then I can read from slaves as well to handle the traffic.所以想如果我可以同步写入(从主到所有在线从),那么我也可以从从读取来处理流量。

  3. How to configure Spring boot project read from any nodes and write to master ?如何配置从任何节点读取并写入 master 的 Spring boot 项目? Currerntly, I am using RedisSentinelConfiguration() to create JedisConnectionFactory.目前,我正在使用 RedisSentinelConfiguration() 创建 JedisConnectionFactory。

Thanks in advance提前致谢

Not familiar with Spring, only answering the first two questions.对Spring不熟悉,只回答前两个问题。

What is the difference between replicaof and slaveof properties? replicaof 和 slaveof 属性有什么区别?

These two terms have the same effect.这两个术语具有相同的效果。 replicaof is introduced since Redis 5. Check this for detail.从 Redis 5 开始引入了replicaof 。查看这个细节。

Is there a property to change this behaviour ie to synchronous replication?是否有更改此行为的属性,即同步复制?

There's no way to change that.没有办法改变这一点。 The WAIT command can be used to mitigate the problem. WAIT命令可用于缓解该问题。 Also you might want to try redisraft , however, it's still in experimental state.您也可能想尝试redisraft ,但是,它仍处于实验状态。

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

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