简体   繁体   English

StackExchange Redis - Net Framework - RedisConnectionException - 无法访问服务 HashSlot

[英]StackExchange Redis - Net Framework - RedisConnectionException - Serving HashSlot Is Not Reachable

Basically am using StackExchangeRedis client to connect to a Redis Cluster with 3 Nodes.基本上是使用StackExchangeRedis客户端连接到具有 3 个节点的 Redis 集群。

My configuration is the following:我的配置如下:

            config.EndPoints.Add(IPAddress.Parse("Node1_IP"), port);
            config.EndPoints.Add(IPAddress.Parse("Node2_IP"), port);
            config.EndPoints.Add(IPAddress.Parse("Node3_IP"), port);

            config.Password = "password";

            config.DefaultDatabase = 0;

            config.ConnectTimeout = ConfigurationOptionsConnectTimeout;
            config.AsyncTimeout = ConfigurationOptionsConnectTimeout;

            config.ConnectRetry = InitialConnectRetries;
            config.ReconnectRetryPolicy = new ExponentialRetry(DeltaBackOffMilliseconds);

            config.AbortOnConnectFail = false;

Node1 HashSlot range is from 0-8191 Node1 HashSlot 范围是0-8191

Node2 HashSlot range is from 8192-16383 Node2 HashSlot 范围是从8192-16383

Node3 has no HashSlot range, it's like a slave i guess. Node3没有 HashSlot 范围,我猜它就像一个奴隶。

Error :错误

StackExchange.Redis.RedisConnectionException: Endpoint Node1_IP:Port serving hashslot 14371 is
 not reachable at this point of time. Please check connectTimeout value. If it is low, try increasing it
 to give the ConnectionMultiplexer a chance to recover from the network disconnect. IOCP: 
(Busy=0,Free=1000,Min=6,Max=1000), WORKER: (Busy=0,Free=8191,Min=6,Max=8191), Local-CPU: n/a

Scenario: Trying to store some key-value in the database.场景:尝试在数据库中存储一些键值。

The above error occurs when my key is hashed(based on Redis hash function) in a hash slot that belongs to Node2 hash slot range.当我的密钥在属于 Node2 哈希槽范围的哈希槽中进行哈希处理(基于 Redis 哈希函数)时,会发生上述错误。 The keys that are hashed in Node 1 hash slot range are stored successfully.在节点 1 散列槽范围内散列的键存储成功。

IF I rearrange the endpoints in the configuration by adding Node2_IP firstly and Node1_IP secondly, then the keys that are hashed in Node2 hash slots can be stored successfully but the keys that are hashed in hash slot range of Node1 produce the same error respectively.如果我通过先添加 Node2_IP 再添加 Node1_IP 重新排列配置中的端点,那么在 Node2 哈希槽中散列的键可以成功存储,但在 Node1 的哈希槽范围内散列的键分别产生相同的错误。

I had another problem but my error message was the same.我有另一个问题,但我的错误信息是一样的。 Maybe this helps you (or somebody else).也许这对你(或其他人)有帮助。

My scenario was that I tried to connect to the cluster from another machine.我的情况是我尝试从另一台机器连接到集群。 I set up the cluster via the example provided by https://redis.io/topics/cluster-tutorial (ie redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1 ).我通过https://redis.io/topics/cluster-tutorial提供的示例设置集群(即redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1 )。

In my code I only provided one of the master nodes (7000 in this case).在我的代码中,我只提供了一个主节点(在本例中为 7000)。 StackExchangeRedis apparently auto discovers the other nodes. StackExchangeRedis显然会自动发现其他节点。 Since I set it up via the above command it tried to connect to 127.0.0.1:7001 which it obviously couldn't.因为我是通过上面的命令设置的,它试图连接到 127.0.0.1:7001 显然不能。 After editing the cluster create command so it uses the public IP address of the server instead of 127.0.0.1, the problem was resolved.编辑 cluster create 命令使其使用服务器的公共 IP 地址而不是 127.0.0.1 后,问题已解决。

I too faced this issue inconsistently, after increasing the connection timeout and setting the CommandFlags.DemandMaster (use this only if its a write operation)在增加连接超时并设置 CommandFlags.DemandMaster 之后,我也不一致地遇到了这个问题(仅当它是写操作时才使用它)

var options = ConfigurationOptions.Parse(host+":"+port);
options.ConnectTimeout = 60000; //60secs

ConnectionMultiplexer
.Connect(options)
.GetDatabase()
.StreamAdd(KeyName, "key", "value", flags: CommandFlags.DemandMaster);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我该如何解决这个错误 StackExchange.Redis.RedisConnectionException: UnableToConnect on redisaec.redis.cache.windows.net:6380/Interactive - how can I solve this error StackExchange.Redis.RedisConnectionException: UnableToConnect on redisaec.redis.cache.windows.net:6380/Interactive 端点xxxx:端口服务哈希槽nnnn在此时间点无法访问 - Endpoint x.x.x.x:port serving hashslot nnnn is not reachable at this point of time StackExchange Redis .NET库中的TimeoutException异常 - TimeoutException exception in StackExchange Redis .NET Library StackExchange.Redis 崩溃 .NET webapi - StackExchange.Redis crashing .NET webapi 多个Redis服务器的.NET Core StackExchange.Redis ConnectionMultiplexer设置 - .NET Core StackExchange.Redis ConnectionMultiplexer setup for multiple redis servers 使用StackExchange.Redis将自定义.Net对象存储在Azure Redis缓存中 - Storing custom .Net objects in Azure Redis Cache with StackExchange.Redis ASP.net MVC中的Azure Redis StackExchange.Redis ConnectionMultiplexer - Azure Redis StackExchange.Redis ConnectionMultiplexer in ASP.net MVC 无法在 .net C# 中连接 AWS Redis 缓存 - RedisConnectionException: '没有连接处于活动状态/可用于服务此操作 - Unable to connect AWS Redis cache in .net C# - RedisConnectionException: 'No connection is active/available to service this operation .net核心中的Stackexchange.Redis超时异常 - Stackexchange.Redis timeout exception in .net-core 无法使用Stackexchange Redis使用.Net中的模式调用HSCAN - Unable to call HSCAN with pattern from .Net using Stackexchange Redis
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM