# 警告：驱逐策略 'allkeys-lru' 与副本上的 'maxmemory-policy' 设置不兼容

- **ID:** `redis/eviction-policy-mismatch`
- **领域:** redis
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

副本节点上配置的驱逐策略与主节点的策略不同，导致复制期间内存管理不一致。

## 版本兼容性

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

## 解决方案

1. ```
   将副本的 maxmemory-policy 与主节点对齐：在副本上运行 CONFIG SET maxmemory-policy allkeys-lru（或匹配主节点的策略）。
   ```
2. ```
   检查两个配置：在主节点和副本上运行 redis-cli CONFIG GET maxmemory-policy，然后永久更新副本的配置文件。
   ```

## 无效尝试

- **Ignore the warning, assuming it's harmless** — Can lead to data inconsistency between master and replica, or unexpected evictions on replica. (50% 失败率)
- **Set a different policy on the replica without matching the master** — Replicas must follow the master's eviction policy to maintain consistency; otherwise, replication may fail. (60% 失败率)
