Redis错误:Cannot determine a partition to read for slot

  • Post author:
  • Post category:其他


今天spring boot使用redis的时候,发生了如下的错误:

io.lettuce.core.cluster.PartitionSelectorException: Cannot determine a partition to read for slot xxx.


上网查找说可能是node被删除了,但是slot没有重新分配,但是我并没有做过删除操作,然后想了想,我的redis集群只有一个节点,最开始搭建redis的时候,没有开启集群功能(用于测试的redis,要求不高),后来为了和main的集群统一,redis开启了集群功能(还是一个节点,,,),然后重启了,怀疑可能是因为开启集群导致的。

调用redis-cli命令检查步骤如下:(其中10.111.111.111:6379是redis的node地址,假的,123456是密码)

首先链接集群尝试:

./redis-cli --cluster reshard 10.111.111.111:6379 -a 123456
#或者
./redis-cli --cluster check 10.111.111.111:6379 -a 123456

结果如下:

Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing Cluster Check (using node 10.113.197.5:6379)
M: 87d66a4ca81b7abfd81b78bbfd2521691f9fbe09 10.113.197.5:6379
   slots: (0 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[ERR] Not all 16384 slots are covered by nodes.

和spring boot基本上一样的错误,证明确实是redis的问题。

然后为了解决上述问题,使用命令进行修复:

./redis-cli --cluster fix 10.111.111.111:6379 -a 123456

中途弹出如下确认:


Fix these slots by covering with a random node? (type 'yes' to accept):

输入yes重新分配slots即可。

然后连接集群发现恢复正常。



版权声明:本文为gao_grace原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。