# 集群健康状态: RED, 未分配分片=5, 原因=由于机架感知约束导致分配失败

- **ID:** `elasticsearch/primary-shard-not-allocated-due-to-rack-awareness`
- **领域:** elasticsearch
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

机架感知分配过滤阻止主分片分配，因为所需机架中没有节点具有足够的磁盘空间或可用。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.17.10 | active | — | — |
| 8.11.0 | active | — | — |
| 8.12.2 | active | — | — |

## 解决方案

1. ```
   临时禁用机架感知分配过滤：PUT _cluster/settings { "transient": { "cluster.routing.allocation.awareness.attributes": "" } }，分片分配后再重新启用
   ```
2. ```
   在所需机架中添加一个节点并确保其有足够的磁盘空间，然后使用集群重路由API：POST _cluster/reroute?retry_failed=true
   ```

## 无效尝试

- **** — The issue is not overall disk space but the specific rack's node availability; increasing space on nodes in other racks does not satisfy the allocation filter (65% 失败率)
- **** — Re-creating the index with fewer shards does not address the rack awareness constraint; the new primary shards will still fail to allocate if the same rack is unavailable (80% 失败率)
