database
protocol_error
ai_generated
true
redis.exceptions.ResponseError:MOVED 12345 192.168.1.10:6379
redis.exceptions.ResponseError: MOVED 12345 192.168.1.10:6379
ID: database/redis-cluster-moved-redirect
90%修复率
85%置信度
1证据数
2024-01-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Redis 6.2 | active | — | — | — |
| Redis 7.0 | active | — | — | — |
| Redis 7.2 | active | — | — | — |
根因分析
Redis集群客户端将命令发送到了错误的节点;该集群槽位由另一个节点拥有,需要重定向。
English
A Redis cluster client sent a command to the wrong node; the cluster slot is owned by a different node, requiring a redirect.
官方文档
https://redis.io/docs/latest/operate/oss_and_stack/management/scaling/解决方案
-
Use a Redis cluster-aware client (e.g., redis-py-cluster) that automatically follows MOVED redirects: from rediscluster import RedisCluster; rc = RedisCluster(startup_nodes=[{'host':'192.168.1.10','port':6379}], decode_responses=True) -
Execute the command on the node specified in the MOVED error: redis-cli -h 192.168.1.10 -p 6379 GET mykey
-
Refresh the cluster slots map in the client: rc.cluster_slots = rc.cluster_slots() to force a re-fetch of slot assignments.
无效尝试
常见但无效的做法:
-
Ignore the MOVED error and retry the same node
100% 失败
The cluster topology is static for that slot; retrying the same node will always fail because the slot is not hosted there.
-
Manually update the client's cluster slots map by hardcoding IP addresses
70% 失败
Cluster nodes can change IPs or rebalance slots; hardcoding breaks when the cluster topology changes.