2

我正在尝试使用 1 个主设备、1 个从设备和 2 个哨兵创建一个简单的 redis 高可用性设置。

当从 故障转移redis-master到时,该设置可以完美运行redis-slave。恢复时redis-master,它正确地将自己注册为新redis-slave主控的从属。

但是,当redis-slave主人倒下时,redis-master 不能作为主人回来。redis-master进入循环的日志显示:

1:S 12 Dec 11:12:35.073 * MASTER <-> SLAVE sync started
1:S 12 Dec 11:12:35.073 * Non blocking connect for SYNC fired the event.
1:S 12 Dec 11:12:35.074 * Master replied to PING, replication can continue...
1:S 12 Dec 11:12:35.075 * Trying a partial resynchronization (request 684581a36d134a6d50f1cea32820004a5ccf3b2d:285273).
1:S 12 Dec 11:12:35.076 * Master is currently unable to PSYNC but should be in the future: -NOMASTERLINK Can't SYNC while not connected with my master
1:S 12 Dec 11:12:36.081 * Connecting to MASTER 10.102.1.92:6379
1:S 12 Dec 11:12:36.081 * MASTER <-> SLAVE sync started
1:S 12 Dec 11:12:36.082 * Non blocking connect for SYNC fired the event.
1:S 12 Dec 11:12:36.082 * Master replied to PING, replication can continue...
1:S 12 Dec 11:12:36.083 * Trying a partial resynchronization (request 684581a36d134a6d50f1cea32820004a5ccf3b2d:285273).
1:S 12 Dec 11:12:36.084 * Master is currently unable to PSYNC but should be in the future: -NOMASTERLINK Can't SYNC while not connected with my master
1:S 12 Dec 11:12:37.087 * Connecting to MASTER 10.102.1.92:6379
1:S 12 Dec 11:12:37.088 * MASTER <-> SLAVE sync started
...

每个Replication doc,它指出:

从 Redis 4.0 开始,当一个实例在故障转移后被提升为 master 时,它仍然能够与旧 master 的 slave 执行部分重新同步。

但日志似乎另有说明。此处提供了显示第一个故障转移和后续日志的更redis-master详细redis-slave的日志redis-slave版本。redis-master

知道发生了什么吗?我必须做些什么才能让redis-master回到主角色?详细配置如下:

服务

NAME             TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)     AGE
redis-master     ClusterIP   10.102.1.92     <none>        6379/TCP    11m
redis-slave      ClusterIP   10.107.0.73     <none>        6379/TCP    11m
redis-sentinel   ClusterIP   10.110.128.95   <none>        26379/TCP   11m

redis-master 配置

requirepass test1234
masterauth test1234
dir /data

tcp-keepalive 60
maxmemory-policy noeviction
appendonly no
bind 0.0.0.0
save 900 1
save 300 10
save 60 10000

slave-announce-ip redis-master.fp8-cache
slave-announce-port 6379

redis-slave 配置

requirepass test1234
slaveof redis-master.fp8-cache 6379
masterauth test1234
dir /data

tcp-keepalive 60
maxmemory-policy noeviction
appendonly no
bind 0.0.0.0
save 900 1
save 300 10
save 60 10000

slave-announce-ip redis-slave.fp8-cache
slave-announce-port 6379
4

1 回答 1

1

事实证明,问题与使用主机名而不是 IP 有关:

slaveof redis-master.fp8-cache 6379
...
slave-announce-ip redis-slave.fp8-cache

所以,当主人作为奴隶回来时,哨兵显示现在有 2 个奴隶:一个有 ip 地址,另一个有主机名。不确定这 2 个从属条目(指向同一个 Redis 服务器)是如何导致上述问题的。现在我将配置更改为使用 IP 地址而不是主机名,Redis HA 工作正常。

于 2018-12-22T15:45:16.247 回答