多数据中心中的 Redis
Redis in Multi Datacenter
我们有很多数据中心,但 datacenter1 是主要的。
datacenter1 中的主节点由 sentinel 监控,因此如果主节点出现故障,副本将成为主节点,并且所有数据都在持续同步。
我们希望在每个数据中心有一个 Redis 副本,从 datacenter1 复制所有数据,但不能成为 master。 (总是从数据中心1获取数据,只有replica 1有能力成为master,其他replica一定不能)
是否有为此或任何想法的 Redis 配置?
Redis Multi Datacenter
Redis 配置 [1] 有一个 replica-priority
参数,应该符合您的目的。
The replica priority is an integer number published by Redis in the INFO
output. It is used by Redis Sentinel in order to select a replica to promote
into a master if the master is no longer working correctly.
A replica with a low priority number is considered better for promotion, so
for instance if there are three replicas with priority 10, 100, 25 Sentinel
will pick the one with priority 10, that is the lowest.
However a special priority of 0 marks the replica as not able to perform the
role of master, so a replica with priority of 0 will never be selected by
Redis Sentinel for promotion.
By default the priority is 100.
想法可以是为数据中心 1 中的副本设置较低的副本优先级值,为其他数据中心中的副本设置较高的副本优先级值。
[1] redis.conf
Redis 版本 6.2.6 的文件:https://github.com/redis/redis/blob/6.2.6/redis.conf
我们有很多数据中心,但 datacenter1 是主要的。
datacenter1 中的主节点由 sentinel 监控,因此如果主节点出现故障,副本将成为主节点,并且所有数据都在持续同步。
我们希望在每个数据中心有一个 Redis 副本,从 datacenter1 复制所有数据,但不能成为 master。 (总是从数据中心1获取数据,只有replica 1有能力成为master,其他replica一定不能)
是否有为此或任何想法的 Redis 配置?
Redis Multi Datacenter
Redis 配置 [1] 有一个 replica-priority
参数,应该符合您的目的。
The replica priority is an integer number published by Redis in the INFO output. It is used by Redis Sentinel in order to select a replica to promote into a master if the master is no longer working correctly.
A replica with a low priority number is considered better for promotion, so for instance if there are three replicas with priority 10, 100, 25 Sentinel will pick the one with priority 10, that is the lowest.
However a special priority of 0 marks the replica as not able to perform the role of master, so a replica with priority of 0 will never be selected by Redis Sentinel for promotion.
By default the priority is 100.
想法可以是为数据中心 1 中的副本设置较低的副本优先级值,为其他数据中心中的副本设置较高的副本优先级值。
[1] redis.conf
Redis 版本 6.2.6 的文件:https://github.com/redis/redis/blob/6.2.6/redis.conf