--- title: "最大投票配置排除数配置" date: 2026-02-04 lastmod: 2026-02-04 description: "控制最大投票配置排除数量的配置项说明" tags: ["集群配置", "投票管理", "节点剔除"] summary: "配置项作用 # cluster.max_voting_config_exclusions 配置项控制集群中允许同时存在的投票配置排除(Voting Config Exclusions)的最大数量。投票配置排除用于从投票配置中临时移除节点,通常用于安全地从集群中移除节点或进行节点维护。 配置项类型 # 该配置项为动态配置,可以在运行时通过集群设置 API 进行修改。 默认值 # 10 是否必需 # 可选配置项(有默认值) 取值范围 # 1 ~ 正整数 配置格式 # # 默认配置 cluster.max_voting_config_exclusions: 10 # 增加限制 cluster.max_voting_config_exclusions: 20 # 减少限制(更严格) cluster.max_voting_config_exclusions: 5 # 最小值 cluster.max_voting_config_exclusions: 1 相关配置项 # 配置项 默认值 说明 cluster.max_voting_config_exclusions 10 最大投票排除数 cluster.auto_shrink_voting_configuration true 自动收缩投票配置 工作原理 # 投票配置排除机制:" --- ## 配置项作用 `cluster.max_voting_config_exclusions` 配置项控制集群中允许同时存在的投票配置排除(Voting Config Exclusions)的最大数量。投票配置排除用于从投票配置中临时移除节点,通常用于安全地从集群中移除节点或进行节点维护。 ## 配置项类型 该配置项为**动态配置**,可以在运行时通过集群设置 API 进行修改。 ## 默认值 ``` 10 ``` ## 是否必需 **可选配置项**(有默认值) ## 取值范围 ``` 1 ~ 正整数 ``` ## 配置格式 ```yaml # 默认配置 cluster.max_voting_config_exclusions: 10 # 增加限制 cluster.max_voting_config_exclusions: 20 # 减少限制(更严格) cluster.max_voting_config_exclusions: 5 # 最小值 cluster.max_voting_config_exclusions: 1 ``` ## 相关配置项 | 配置项 | 默认值 | 说明 | |-------|-------|------| | `cluster.max_voting_config_exclusions` | 10 | 最大投票排除数 | | `cluster.auto_shrink_voting_configuration` | true | 自动收缩投票配置 | ## 工作原理 投票配置排除机制: ``` ┌─────────────────────────────────────────────────────────────────┐ │ 投票配置排除 │ └─────────────────────────────────────────────────────────────────┘ 添加投票排除请求 │ ▼ 检查当前排除数量 │ ├── 当前数量 < max_voting_config_exclusions │ │ │ └── 允许添加排除 │ └── 当前数量 >= max_voting_config_exclusions │ └── 拒绝请求,返回错误 投票排除生效后 │ ├── 节点从投票配置中移除 │ └── 可以安全移除节点 ``` ## 使用场景 ### 1. 默认配置(推荐) ```yaml cluster.max_voting_config_exclusions: 10 ``` 适用于大多数集群配置。 ### 2. 大规模集群 ```yaml cluster.max_voting_config_exclusions: 20 ``` **适用场景:** - 大规模节点集群 - 频繁节点维护 - 批量节点替换 ### 3. 小型集群 ```yaml cluster.max_voting_config_exclusions: 3 ``` **适用场景:** - 小型集群 - 严格保护投票配置 - 防止误操作 ### 4. 最严格配置 ```yaml cluster.max_voting_config_exclusions: 1 ``` **适用场景:** - 关键业务集群 - 需要谨慎操作 - 逐个移除节点 ## 推荐设置建议 | 集群规模 | 推荐值 | 说明 | |---------|-------|------| | 小型(3-5节点) | 3-5 | 保守配置 | | 中型(6-20节点) | 10 | 默认配置 | | 大型(20+节点) | 15-20 | 支持批量操作 | | 生产环境 | 5-10 | 安全优先 | ## 操作流程 添加投票配置排除的标准流程: ```bash # 1. 添加投票配置排除 POST /_cluster/voting_config_exclusions/node_name1,node_name2 # 2. 等待节点从投票配置中移除 GET /_cluster/state?filter_path=metadata.coordination.voting_config_exclusions # 3. 从集群移除节点 PUT /_cluster/settings { "persistent": { "cluster.routing.allocation.exclude._host": "node1_hostname" } } # 4. 清理投票配置排除 DELETE /_cluster/voting_config_exclusions ``` ## 动态配置示例 ```bash # 更新集群配置 PUT /_cluster/settings { "transient": { "cluster.max_voting_config_exclusions": 15 } } ``` ## 监控建议 ```bash # 查看当前配置 GET /_cluster/settings?filter_path=*.cluster.max_voting_config_exclusions # 查看投票排除状态 GET /_cluster/state?filter_path=metadata.coordination.voting_config_exclusions # 查看投票配置 GET /_cluster/state?filter_path=metadata.coordination.voting_config ``` ## 注意事项 1. **动态更新**:此配置为动态配置,可在线修改 2. **集群稳定性**:防止一次性移除过多投票节点 3. **最小值限制**:最小值为 1,不能设置为 0 4. **配合自动收缩**:与 auto_shrink_voting_configuration 配合使用 5. **操作谨慎**:投票配置变更影响集群选举能力