# redis.exceptions.ResponseError：MOVED 12345 192.168.1.10:6379

- **ID:** `database/redis-cluster-moved-redirect`
- **领域:** database
- **类别:** protocol_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

Redis集群客户端将命令发送到了错误的节点；该集群槽位由另一个节点拥有，需要重定向。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Redis 6.2 | active | — | — |
| Redis 7.0 | active | — | — |
| Redis 7.2 | active | — | — |

## 解决方案

1. ```
   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)
   ```
2. ```
   Execute the command on the node specified in the MOVED error: redis-cli -h 192.168.1.10 -p 6379 GET mykey
   ```
3. ```
   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** — The cluster topology is static for that slot; retrying the same node will always fail because the slot is not hosted there. (100% 失败率)
- **Manually update the client's cluster slots map by hardcoding IP addresses** — Cluster nodes can change IPs or rebalance slots; hardcoding breaks when the cluster topology changes. (70% 失败率)
