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 master(ip:'10.0.0.68',端口:'6379'),然后与其建立连接。但有时,Kubernetes 服务会返回(ip:'10.0.0.68',端口:'6379'),有时,它会返回 Kubernetes 服务(10.3.251.152,26379/TCP)作为哨兵主 IP。我们可以在程序日志中看到这些来与哨兵大师连接
在这两种情况(kubernetes sentinel 示例、helm.sh 的 redis 集群)情况下都会发生这种不一致。
您可以在此处查看服务和 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 ..
}
}
更多关于master/slave/sentinel的详细信息
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' }
如何排除故障?
查看 Redis Sentinel Gateway — 它有助于管理 Redis 故障转移,而无需在应用程序代码中实现 Sentinel 支持。非常适合需要高可用性的遗留应用程序!