我正在使用StackExchange.Redis寻找高可用性。
我的第一种方法是尝试使用Redis Sentinel,但由于该软件包的功能而没有成功。
我在Docker中有一个6节点的集群(3个主节点和3个从节点)。当我关闭或暂停主容器时,我的应用程序能够连接到这3个主数据库,但我的应用程序抛出 RedisTimeoutException ,因为它无法访问之前连接的节点。
这是运行cluster nodes
命令before
暂停母版的输出
这是运行cluster nodes
命令after
暂停母版的输出
这是我的应用抛出的异常
目前,我正在连接3位大师
private const string Host = "10.0.0.2:7000, 10.0.0.3:7001, 10.0.0.4:7002";
private static readonly ConnectionMultiplexer Connection = ConnectionMultiplexer.Connect(Host);
最佳答案
尝试使用
RedisClusterConfiguration redisClusterConfiguration = new RedisClusterConfiguration(nodesList);
这将需要连接到Redis Cluster。
关于.net - 如何在StackExchange.Redis中使用Redis群集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55110228/