Kubernetes 服务Redis Sentinel 没有始终如一地返回 Redis 主 IP 和端口,并且所有 pod 都在 docker 容器中。我已经使用了https://github.com/kubernetes/kubernetes/tree/master/examples/redis和 https://github.com/helm/helm - redis 集群
当我连接到 Kubernetes 服务(10.3.251.152、26379/TCP)时,它应该确定 Redis Sentinel 主机(ip:'10.0.0.68',端口:'6379'),然后与它建立连接。但有时,Kubernetes 服务返回 (ip: '10.0.0.68', port: '6379') 和其他时候,它返回 Kubernetes 服务 (10.3.251.152 , 26379/TCP) 作为哨兵主 IP。我们可以在程序 Log to connect with sentinel master中看到这一点
在这两种情况下(kubernetes sentinel example,helm.sh's redis cluster)都会发生这种不一致。
您可以在此处查看服务和 pod 详细信息..
useRedisSentinel true
redisSentinelHost 10.3.251.152 redisSentinelPort 26379
Queueing psubscribe for next server connection.
sentinelClient { domain: null,
_events:
{ 'sentinel disconnected': [Function],
'failover start': [Function],
'switch master': [Function] },
_maxListeners: undefined,
options:
{ master_debug: true,
port: '26379',
host: '10.3.251.152',
and so on ..
}
}
有关主/从/哨兵详细信息的更多详细信息
masters [ { name: 'mymaster',
ip: '10.0.0.68',
port: '6379',
runid: '33798857c71ebf2c85c7095291d453cb143cea7e',
flags: 'master',
'pending-commands': '0',
'last-ok-ping-reply': '0',
'last-ping-reply': '518',
'info-refresh': '518',
'num-slaves': '60000',
'num-other-sentinels': '9021',
quorum: 'master' } ]
mymaster slaves [ { name: '10.0.0.70:6379',
ip: '10.0.0.70',
port: '6379',
runid: 'ce2330d9071e091e8d808017d761cbdae1d286b9',
flags: 'slave',
'pending-commands': '0',
'last-ok-ping-reply': '0',
'last-ping-reply': '518',
'info-refresh': '518',
'master-link-down-time': '60000',
'master-link-status': '9021',
'master-host': 'slave',
'master-port': '33297880',
'slave-priority': '0' },
{ name: '10.0.0.69:6379',
ip: '10.0.0.69',
port: '6379',
runid: 'a1e063c71a4ef93a8c5769aa29cb1d8dbf669579',
flags: 'slave',
'pending-commands': '0',
'last-ok-ping-reply': '0',
'last-ping-reply': '518',
'info-refresh': '518',
'master-link-down-time': '60000',
'master-link-status': '9021',
'master-host': 'slave',
'master-port': '33297888',
'slave-priority': '0' } ]
mymaster sentinels [ { name: '10.0.0.71:26379',
ip: '10.0.0.71',
port: '26379',
runid: '6f787783753fa446c6ecb118d07339d51f1fda14',
flags: 'sentinel',
'pending-commands': '0',
'last-ok-ping-reply': '0',
'last-ping-reply': '518',
'last-hello-message': '518',
'can-failover-its-master': '60000' },
{ name: '10.0.0.68:26379',
ip: '10.0.0.68',
port: '26379',
runid: '7542fbbb0c36c4d171c10b492f67a416d794fc96',
flags: 'sentinel',
'pending-commands': '0',
'last-ok-ping-reply': '0',
'last-ping-reply': '518',
'last-hello-message': '518',
'can-failover-its-master': '60000' } ]
mymaster getMasterAddress { ip: '10.0.0.68', port: '6379' }
如何进行故障排除?