# MOVED 12182 10.0.0.1:6379：Redis 集群重定向到不同节点

- **ID:** `communication/redis-cluster-moved-redirect`
- **领域:** communication
- **类别:** protocol_error
- **错误码:** `MOVED`
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

Redis 集群客户端将命令发送到不拥有该键哈希槽的节点，且客户端未使用智能客户端路由或集群感知的连接池。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Redis 6.2 | active | — | — |
| Redis 7.0 | active | — | — |
| Redis 7.2 | active | — | — |
| ioredis 5.3 | active | — | — |
| redis-py 4.5 | active | — | — |

## 解决方案

1. ```
   使用支持 Redis 集群的客户端库自动处理 MOVED 重定向，例如 ioredis Cluster：`new Redis.Cluster([{ host: '10.0.0.1', port: 6379 }])`，它会维护槽到节点的映射。
   ```
2. ```
   在客户端配置中启用集群模式并自动刷新槽信息，例如在 redis-py 中：`rediscluster.RedisCluster(startup_nodes=[{'host':'10.0.0.1','port':6379}], skip_full_coverage_check=True)`。
   ```
3. ```
   如果使用非集群感知客户端，实现手动重试并计算槽位：使用 CRC16 对键取模 16384 计算哈希槽，然后直接连接到正确节点。
   ```

## 无效尝试

- **Manually redirect the client to the node IP in the MOVED error without updating the cluster topology** — The cluster topology may change again; manual redirection is not scalable and can cause further MOVED errors. (70% 失败率)
- **Disable cluster mode and connect to a single Redis instance** — Defeats the purpose of clustering; data may be incomplete or inconsistent across nodes. (90% 失败率)
- **Increase connection timeout in client configuration** — Timeout does not address the routing issue; MOVED is a protocol-level redirect, not a timeout. (85% 失败率)
