简体   繁体   English

Redis哨兵故障转移后返回旧主机

[英]Return old master after redis sentinel failover

I have 3 box setup of redis sentinel: 我有3个盒子的redis前哨设置:

 CLIENT (connects to S1)
          |
          ↓
       +----+
       | M1 | us-east-1
       | S1 |
       +----+
          |
+----+    |    +----+
| R2 |----+----| R3 |
| S2 |         | S3 |
+----+         +----+
us-east-2      us-west-2

M1 - Master
S1 - Sentinel 1
S2 - Sentinel 2
S3 - Sentinel 3
R2 - First slave (R=replica)
R3 - Second slave

After my master died, sentinel made a failover to R2. 我的主人去世后,哨兵将故障转移到R2。 I brought back M1 online (cleared some disk space) and now M1 is alive and well but a slave of R2. 我使M1重新联机(清除了一些磁盘空间),现在M1仍然运行并且很好,但是是R2的从属。 Is there an automatic way (or semi-automatic) to make M1 a master again and R2 as a slave of M1 and my traffic again using M1 as a master redis instance? 是否有一种自动方式(或半自动方式)使M1再次成为主节点,使R2成为M1的从节点,并再次使我的流量使用M1作为主Redis实例?

Essentially I want to revert to how it was prior to failover. 本质上,我想恢复到故障转移之前的状态。

What currently happens is that it elects R2 as a master and reconfigures it to be: 当前发生的情况是,它选择R2作为主机,并将其重新配置为:

CLIENT (connects to S1)
          |
          ↓
       +----+
       |[R2]| us-east-2
       | S2 |
       +----+
          |
+----+    |    +----+
|[M1]|----+----| R3 |
| S1 |         | S3 |
+----+         +----+
us-east-1      us-west-2

When I failover manually, it promotes R3 as master. 当我手动进行故障转移时,它会将R3提升为主服务器。 (which is kind of expected). (这是预料之中的)。

But then when I failover again manually, it promotes R2, but I would expect it to promote M1. 但是,当我再次手动进行故障转移时,它会提升R2,但我希望它会提升M1。

All successive failovers rotate between R2 and R2 (while always keeping M1 as a slave of either). 所有连续的故障转移都在R2和R2之间旋转(同时始终保持M1作为其中一个的从属)。

My M1 slave priority is unspecified, so it means it's a default value of 100. My R2 slave priority is 200 and R2 is 300. That leads me to think that it should rotate all 3 of the boxes, but it rotates only R2 and R3 after the initial failover. 我的M1从属优先级未指定,因此它的默认值为100。我的R2从属优先级为200,R2为300。这使我认为它应该旋转所有三个框,但只旋转R2和R3初始故障转移后。

This looks like a sentinel bug to me 对我来说这看起来像是哨兵的虫子

I am not sure why you want to do that in first place. 我不确定为什么要首先这样做。 Redis failing over to R2 and using at as master now should perfectly work as normal M1 instance. Redis故障转移到R2并以at作为主设备使用,现在应该可以正常作为M1实例正常工作。 If that's not the case, you are not actually using Sentinel correctly for high availability. 如果不是这种情况,则说明您实际上并未正确使用Sentinel来实现高可用性。

You can just trigger a manual failover with SENTINEL failover R2 . 您可以使用SENTINEL failover R2触发手动故障 SENTINEL failover R2 It should switch to either M1 or R3. 它应该切换到M1或R3。

I think kiddorails's answer is correct, but most probably you have a similar problem as I had, where for some reason your original master is not replicating correctly. 我认为kiddorails的答案是正确的,但是很可能您遇到了与我类似的问题,由于某种原因,您的原始母版无法正确复制。 Once I fixed my replication issue, I could cycle through my masters by issueing SENTINEL FAILOVER mymaster . 解决复制问题后,我可以通过发出SENTINEL FAILOVER mymaster来遍历所有主SENTINEL FAILOVER mymaster Initially it would just bounce between the two original slaves, but now that my original master is correctly replicating, it is cycling through all 3. So I would recommend checking the replication of your original master after a failover. 最初,它只是在两个原始从属服务器之间反弹,但是现在我的原始主服务器正在正确复制,它会循环遍历所有3个。因此,我建议在故障转移后检查原始主服务器的复制。 if you are sure it is working, you could also stop the other slave and then use the SENTINEL FAILOVER mymaster command to force a failover to the original master. 如果确定运行正常,则还可以停止另一个从属服务器,然后使用SENTINEL FAILOVER mymaster命令将故障转移强制到原始主服务器。 If that fails, you know there must be an issue with the replication. 如果失败,则说明复制一定存在问题。

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

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