这可能是sure错误或堆栈溢出问题,我还不确定:
我已经建立了一个简单的三节点Redis系统,其中有一个主节点和两个副本节点,使用管理故障转移。使用Redis内置的TLS支持和普通CA颁发的证书来保护Redis和哨兵网络流量。
每个哨兵实例被配置为宣布其主机名并解析DNS:
sentinel resolve-hostnames yes
sentinel announce-hostnames yes
sentinel announce-ip "redistest2.mydomain.com"我们有一个使用Servicestack连接到Sentinel实例的web服务。只要我们不验证TLS证书和主机名,一切都运行良好: web服务可以看到Redis Sentinel侦听器,并且当我们终止当前Master时,Redis集群会投票给一个新的主机,并且web服务切换到新的可写Redis节点。
但是,当原始主节点使用其FQDN报告时,这两个备份节点似乎只向ServiceStack报告了它们的IP地址。
Sentinel日志摘录表明备份节点似乎使用了它们的主机名:
28011:X 15 Feb 2023 15:23:10.817 * +sentinel sentinel <hex-string> redistest2.mydomain.com 26379 @ redistest redistest1.mydomain.com 6379
28011:X 15 Feb 2023 15:23:10.821 * Sentinel new configuration saved on disk
28011:X 15 Feb 2023 15:23:10.897 * +sentinel sentinel <other-hex-string> redistest3.mydomain.com 26379 @ redistest redistest1.mydomain.com 6379
28011:X 15 Feb 2023 15:23:10.901 * Sentinel new configuration saved on disk然而,ServiceStack坚持它只接收来自服务器组的服务器IP地址:
Starting with sentinel.
Sentinel hosts: redistest1.mydomain.com:26379?ssl=true, redistest2.mydomain.com:26379?ssl=true, redistest3.mydomain.com:26379?ssl=true
Sentinel created
Host filter set.
Hostfilter: redistest1.mydomain.com:6379
Hostfilter: 10.100.60.72:6379
Hostfilter: 10.100.60.73:6379
RedisManager started.
Redis sentinel info: redistest primary: redistest1.mydomain.com:6379, replicas: 10.100.60.72:6379, 10.100.60.73:6379
Hostfilter: 10.100.60.72:6379
Hostfilter: 10.100.60.73:6379
Ping error with read only client: ServiceStack.Redis.RedisException: [14:23:47.626] Unable to Connect: sPort: 0, Error: One or more errors occurred.
(...)
---> System.AggregateException: One or more errors occurred. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.在Redis和/或哨兵配置端,我还能做些什么来确保ServiceStack接收到Redis节点的实际主机名,以便我们正确地验证所使用的证书吗?
发布于 2023-02-16 06:36:17
ServiceStack日志包含错误所在的必要线索:哨兵做了它应该做的事情,但是IP地址引用了Redis备份节点。
类似于哨兵如何在sentinel announce-ip配置语句中返回包含FQDN的字符串,Redis也可以对replica-announce-ip配置语句执行相同的操作。
解决方案是在所有备份主机上向Redis配置文件添加以下行:
replica-announce-ip servername.mydomain.com在本例中,Servername当然是运行此特定备份节点的机器的主机名。
https://serverfault.com/questions/1123017
复制相似问题