📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

配置项作用 #

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. 静态配置:修改需要重启节点
  2. 集群启动:影响集群启动速度
  3. 高可用性:设置为实际节点数可防止脑裂
  4. 维护窗口:维护期间可能需要调整此值
  5. 默认值:-1 表示不设置期望

相关配置项 #

配置项默认值说明
gateway.recover_after_data_nodes-1恢复所需最小数据节点数
gateway.recover_after_time0ms恢复延迟时间

完整配置示例 #

# easysearch.yml

# 3 节点集群配置
gateway.expected_data_nodes: 3
gateway.recover_after_data_nodes: 2
gateway.recover_after_time: 1m