--- title: "节点并发恢复数量配置" date: 2026-03-11 lastmod: 2026-03-11 description: "控制单节点上并发分片恢复数量的配置项说明" tags: ["集群配置", "分片恢复", "节点管理"] summary: "配置项作用 # cluster.routing.allocation.node_concurrent_recoveries 配置项控制每个节点上允许同时进行的分片恢复操作的最大数量。此配置用于防止节点因过多的并发恢复操作而过载。 配置项类型 # 该配置项为动态配置,可以在运行时通过集群设置 API 进行修改。 默认值 # 2 是否必需 # 可选配置项(有默认值) 取值范围 # 0 ~ 正整数 配置格式 # # 默认配置 cluster.routing.allocation.node_concurrent_recoveries: 2 # 增加并发恢复数量 cluster.routing.allocation.node_concurrent_recoveries: 4 # 不限制并发恢复 cluster.routing.allocation.node_concurrent_recoveries: 10 # 限制恢复操作 cluster.routing.allocation.node_concurrent_recoveries: 1 相关配置项 # 配置项 默认值 说明 cluster.routing.allocation.node_concurrent_recoveries 2 总体并发恢复数量 cluster.routing.allocation.node_concurrent_incoming_recoveries 2 入站恢复数量(默认继承总体值) cluster.routing.allocation.node_concurrent_outgoing_recoveries 2 出站恢复数量(默认继承总体值) cluster." --- ## 配置项作用 `cluster.routing.allocation.node_concurrent_recoveries` 配置项控制每个节点上允许同时进行的分片恢复操作的最大数量。此配置用于防止节点因过多的并发恢复操作而过载。 ## 配置项类型 该配置项为**动态配置**,可以在运行时通过集群设置 API 进行修改。 ## 默认值 ``` 2 ``` ## 是否必需 **可选配置项**(有默认值) ## 取值范围 ``` 0 ~ 正整数 ``` ## 配置格式 ```yaml # 默认配置 cluster.routing.allocation.node_concurrent_recoveries: 2 # 增加并发恢复数量 cluster.routing.allocation.node_concurrent_recoveries: 4 # 不限制并发恢复 cluster.routing.allocation.node_concurrent_recoveries: 10 # 限制恢复操作 cluster.routing.allocation.node_concurrent_recoveries: 1 ``` ## 相关配置项 | 配置项 | 默认值 | 说明 | |-------|-------|------| | `cluster.routing.allocation.node_concurrent_recoveries` | 2 | 总体并发恢复数量 | | `cluster.routing.allocation.node_concurrent_incoming_recoveries` | 2 | 入站恢复数量(默认继承总体值) | | `cluster.routing.allocation.node_concurrent_outgoing_recoveries` | 2 | 出站恢复数量(默认继承总体值) | | `cluster.routing.allocation.node_initial_primaries_recoveries` | 4 | 初始主分片恢复数量 | ## 工作原理 恢复并发控制机制: ``` ┌─────────────────────────────────────────────────────────────────┐ │ 节点恢复并发控制 │ └─────────────────────────────────────────────────────────────────┘ 分片恢复请求 │ ▼ 检查当前恢复状态 │ ├── 入站恢复(incoming_recoveries) │ │ │ ├── 节点正在接收的分片数量 │ └── 与 node_concurrent_incoming_recoveries 比较 │ └── 出站恢复(outgoing_recoveries) │ ├── 节点正在发送的分片数量 └── 与 node_concurrent_outgoing_recoveries 比较 ``` ## 恢复类型说明 ### 1. 入站恢复(Incoming Recoveries) 节点作为目标节点,接收来自其他节点的分片数据: - 副本分片恢复 - 分片迁移后的恢复 ### 2. 出站恢复(Outgoing Recoveries) 节点作为源节点,向其他节点发送分片数据: - 主分片向副本分片发送数据 - 分片迁移时发送数据 ## 使用场景 ### 1. 默认配置(推荐) ```yaml cluster.routing.allocation.node_concurrent_recoveries: 2 ``` 适用于大多数生产环境。 ### 2. 高性能存储 ```yaml cluster.routing.allocation.node_concurrent_recoveries: 6 ``` **适用场景:** - SSD 存储环境 - 高带宽网络 - 需要快速恢复 ### 3. 低性能环境 ```yaml cluster.routing.allocation.node_concurrent_recoveries: 1 ``` **适用场景:** - HDD 存储 - 有限网络带宽 - 避免过载 ### 4. 分别控制入站和出站 ```yaml cluster.routing.allocation.node_concurrent_incoming_recoveries: 4 cluster.routing.allocation.node_concurrent_outgoing_recoveries: 2 ``` **效果:** - 允许更多分片进入节点 - 限制从节点发出的恢复操作 ## 推荐设置建议 | 存储类型 | 推荐值 | 说明 | |---------|-------|------| | HDD | 1-2 | 避免磁盘 I/O 过载 | | SATA SSD | 2-4 | 中等并发度 | | NVMe SSD | 4-8 | 高性能可提高并发 | | 网络存储 | 1-2 | 考虑网络带宽 | ## 监控建议 ```bash # 查看当前配置 GET /_cluster/settings?filter_path=*.cluster.routing.allocation.node_concurrent_recoveries # 查看正在恢复的分片 GET /_cat/recovery?v # 查看节点恢复状态 GET /_cat/nodes?v&h=name,host,relocating_shards ``` ## 注意事项 1. **动态更新**:此配置为动态配置,可在线修改 2. **继承关系**:`node_concurrent_incoming_recoveries` 和 `node_concurrent_outgoing_recoveries` 默认继承此配置的值 3. **存储性能**:根据磁盘 I/O 性能调整并发度 4. **网络带宽**:恢复操作会占用大量网络带宽 5. **初始恢复**:此配置不包括初始主分片恢复,需要单独配置 `node_initial_primaries_recoveries`