.net - 如何在StackExchange.Redis中使用Redis群集?

标签 .net redis stackexchange.redis

我正在使用StackExchange.Redis寻找高可用性。
我的第一种方法是尝试使用Redis Sentinel,但由于该软件包的功能而没有成功。

我在Docker中有一个6节点的集群(3个主节点和3个从节点)。当我关闭或暂停主容器时,我的应用程序能够连接到这3个主数据库,但我的应用程序抛出 RedisTimeoutException ,因为它无法访问之前连接的节点。

这是运行cluster nodes命令before暂停母版的输出
enter image description here

这是运行cluster nodes命令after暂停母版的输出
enter image description here

这是我的应用抛出的异常
enter image description here

目前,我正在连接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/

相关文章:

c# - 如果先前已获取锁,如何使用 Monitor 类和对象锁来防止方法执行

.net - 如何在Windows容器中使用dotnet监视器收集应用程序指标

redis - 如何在此 Redis Sentinel 配置中切换主节点?

go - Redis `TIME` 集群模式命令

azure - Redis 缓存中的 key 不可用

c# - 在多个类之间共享变量

c# - 如何从 DataTable 对象中知道行索引

spring-boot - Redis 在使用 Spring Boot 时将对象设置为空 json "{}"

c# - Redis Server 失败,Socket 失败,超出输出缓冲区限制,我该如何增加限制?

redis - StackExchange.Redis 如何使用多个端点和连接?