配置项作用 #
gateway.expected_data_nodes 配置项指定集群启动恢复前期望的数据节点数量。集群会等待直到达到指定数量的数据节点才开始恢复。
是否可选 #
是
默认值 #
-1 (不设置期望)
配置项类型 #
静态配置 - 需要重启节点才能生效
配置格式 #
# 默认配置(不设置期望)
gateway.expected_data_nodes: -1
# 指定期望节点数
gateway.expected_data_nodes: 3
# 大型集群
gateway.expected_data_nodes: 10
工作原理 #
┌─────────────────────────────────────────────────────────┐
│ 集群启动流程 │
└─────────────────────────────────────────────────────────┘
节点启动
│
▼
检查 expected_data_nodes
│
├── 设置为 -1
│ └── 立即开始恢复
│
└── 设置为 N
│
▼
统计数据节点数
│
├── 节点数 < N → 等待
│
└── 节点数 >= N → 开始恢复
推荐设置 #
| 集群规模 | 推荐值 | 说明 |
|---|---|---|
| 小型集群 | 实际数据节点数 | 确保所有节点加入 |
| 中型集群 | 最小数据节点数 | 保证基本可用性 |
| 大型集群 | 实际数据节点数的 2/3 | 允许部分节点故障 |
使用示例 #
小型集群(3 数据节点):
gateway.expected_data_nodes: 3
大型集群(10 数据节点):
# 允许 3 个节点故障
gateway.expected_data_nodes: 7
开发环境(单节点):
gateway.expected_data_nodes: 1
配置验证 #
# 查看当前配置
GET /_cluster/settings?filter_path=*.gateway.expected_data_nodes
# 查看数据节点数
GET /_cat/nodes?v&h=name,node.role,data
注意事项 #
- 静态配置:修改需要重启节点
- 集群启动:影响集群启动速度
- 高可用性:设置为实际节点数可防止脑裂
- 维护窗口:维护期间可能需要调整此值
- 默认值:-1 表示不设置期望
相关配置项 #
| 配置项 | 默认值 | 说明 |
|---|---|---|
gateway.recover_after_data_nodes | -1 | 恢复所需最小数据节点数 |
gateway.recover_after_time | 0ms | 恢复延迟时间 |
完整配置示例 #
# easysearch.yml
# 3 节点集群配置
gateway.expected_data_nodes: 3
gateway.recover_after_data_nodes: 2
gateway.recover_after_time: 1m





