简体   繁体   English

当 Redis 处于哨兵模式时,是否有可能在复制之前发生读取?

[英]Is it possible read happens before replication when Redis is in sentinel mode?

I am running Redis in sentinels mode, It has happened many times that I write data in Redis but while reading same key I don't get expected value.我在哨兵模式下运行 Redis,我在 Redis 中写入数据已经发生了很多次,但是在读取相同的键时我没有得到预期的值。

I am wondering if it is possible when I write data it is written on Master and while reading it goes to slave but since Replication in Redis is asynchronous in nature all slaves are not updated and hence I don't get updated value/ valid value.我想知道是否有可能当我写入数据时,它是写在 Master 上的,而当读取它时,它会转到从机,但是由于 Redis 中的复制本质上是异步的,所以所有从机都没有更新,因此我没有得到更新的值/有效值。

I am using redisson client and three servers for sentinel configuration.我正在使用 redisson 客户端和三个服务器进行哨兵配置。

It's not possible.这是不可能的。 To overcome this you may choose from follow options:为了克服这个问题,您可以选择以下选项:

  1. set readMode config parameter to MASTERreadMode配置参数设置为MASTER
  2. use RBatch object with defined syncSlaves setting BatchOptions.syncSlaves(2, 10, TimeUnit.SECONDS)使用具有定义的 syncSlaves 设置的RBatch对象BatchOptions.syncSlaves(2, 10, TimeUnit.SECONDS)

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

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