Redis sentinel - 如何让服务器脱离循环?
Redis sentinel - How to take a server out of loop?
我部署了 sentinel - 3 个 redis 实例在不同的服务器上,每个服务器上有 3 个 sentinel。
现在,我意识到当前的 master 没有太多内存,所以我停止了这个特定服务器上的 sentinel 和 redis 实例。并在新机器上进行了相同的设置。所以,我仍然有相同的部署,3 个 redis 实例和 3 个哨兵。
问题是,现在哨兵说,master 宕机了,因为他们认为 master 是我删除的服务器。我应该怎么做才能告诉哨兵它不需要在循环中包含该服务器。
来自关于 Redis Sentinel 的文档,在 Adding or removing Sentinels 章下:
Removing a Sentinel is a bit more complex: Sentinels never forget already seen Sentinels, even if they are not reachable for a long time, since we don't want to dynamically change the majority needed to authorize a failover and the creation of a new configuration number. So in order to remove a Sentinel the following steps should be performed in absence of network partitions:
- Stop the Sentinel process of the Sentinel you want to remove.
- Send a
SENTINEL RESET *
command to all the other Sentinel instances (instead of * you can use the exact master name if you want to reset just a single master). One after the other, waiting at least 30 seconds between instances.
- Check that all the Sentinels agree about the number of Sentinels currently active, by inspecting the output of
SENTINEL MASTER mastername
of every Sentinel.
进一步:
Removing the old master or unreachable slaves.
Sentinels never forget about slaves of a given master, even when they are unreachable for a long time. This is useful, because Sentinels should be able to correctly reconfigure a returning slave after a network partition or a failure event.
Moreover, after a failover, the failed over master is virtually added as a slave of the new master, this way it will be reconfigured to replicate with the new master as soon as it will be available again.
However sometimes you want to remove a slave (that may be the old master) forever from the list of slaves monitored by Sentinels.
In order to do this, you need to send a SENTINEL RESET mastername
command to all the Sentinels: they'll refresh the list of slaves within the next 10 seconds, only adding the ones listed as correctly replicating from the current master INFO
output.
我部署了 sentinel - 3 个 redis 实例在不同的服务器上,每个服务器上有 3 个 sentinel。
现在,我意识到当前的 master 没有太多内存,所以我停止了这个特定服务器上的 sentinel 和 redis 实例。并在新机器上进行了相同的设置。所以,我仍然有相同的部署,3 个 redis 实例和 3 个哨兵。
问题是,现在哨兵说,master 宕机了,因为他们认为 master 是我删除的服务器。我应该怎么做才能告诉哨兵它不需要在循环中包含该服务器。
来自关于 Redis Sentinel 的文档,在 Adding or removing Sentinels 章下:
Removing a Sentinel is a bit more complex: Sentinels never forget already seen Sentinels, even if they are not reachable for a long time, since we don't want to dynamically change the majority needed to authorize a failover and the creation of a new configuration number. So in order to remove a Sentinel the following steps should be performed in absence of network partitions:
- Stop the Sentinel process of the Sentinel you want to remove.
- Send a
SENTINEL RESET *
command to all the other Sentinel instances (instead of * you can use the exact master name if you want to reset just a single master). One after the other, waiting at least 30 seconds between instances.- Check that all the Sentinels agree about the number of Sentinels currently active, by inspecting the output of
SENTINEL MASTER mastername
of every Sentinel.
进一步:
Removing the old master or unreachable slaves.
Sentinels never forget about slaves of a given master, even when they are unreachable for a long time. This is useful, because Sentinels should be able to correctly reconfigure a returning slave after a network partition or a failure event.
Moreover, after a failover, the failed over master is virtually added as a slave of the new master, this way it will be reconfigured to replicate with the new master as soon as it will be available again.
However sometimes you want to remove a slave (that may be the old master) forever from the list of slaves monitored by Sentinels.
In order to do this, you need to send a
SENTINEL RESET mastername
command to all the Sentinels: they'll refresh the list of slaves within the next 10 seconds, only adding the ones listed as correctly replicating from the current masterINFO
output.