# 主分片未分配异常：主分片 [my_index][0] 未分配，因为节点版本 [7.10.2] 与索引版本 [7.17.0] 不兼容

- **ID:** `elasticsearch/primary-shard-not-allocated-due-to-node-version-mismatch`
- **领域:** elasticsearch
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

较旧版本的 Elasticsearch 节点无法托管由较新版本创建的主分片，因为 Lucene 段格式不兼容。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.10.2 | active | — | — |
| 7.17.0 | active | — | — |
| 8.0.0 | active | — | — |

## 解决方案

1. ```
   Upgrade the older node's Elasticsearch version to match the index version (e.g., from 7.10.2 to 7.17.0) using rolling upgrade: `sudo systemctl stop elasticsearch`, replace package, restart, and wait for shard allocation.
   ```
2. ```
   Reindex the data to a new index with compatible settings: `POST _reindex { "source": { "index": "my_index" }, "dest": { "index": "my_index_v2" } }` then delete old index and use alias.
   ```

## 无效尝试

- **** — Node version does not change on restart; manual upgrade is required. (95% 失败率)
- **** — Data is lost and the root cause (version mismatch) remains if other nodes are still newer. (85% 失败率)
