解决 Elasticsearch 报错 cluster_block_exception FORBIDDEN 12 index read-only 磁盘只读锁修复
排查 Elasticsearch 写入报错 FORBIDDEN/12/index read-only / allow delete (api) [flood_stage disk watermark [95%] exceeded on one or more nodes],分析 水位线策略与索引只读锁解除。
问题现象
向现有索引写入文档时,应用接口报 403 Forbidden 错误:
{
"error": {
"root_cause": [{"type": "cluster_block_exception", "reason": "index [logs-2026.11.16] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}],
"type": "cluster_block_exception",
"reason": "index [logs-2026.11.16] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"
},
"status": 403
}
触发根因
- Elasticsearch 保护机制触发了洪水级磁盘水位(Flood Stage Disk Watermark),默认节点磁盘使用率超过 95% 时集群自动将所有索引设置为只读;
- 历史日志索引未配置生命周期管理(ILM),过往归档数据填满本地磁盘分区;
- 即使清理磁盘释放空间后,索引上的
read_only_allow_delete属性不会自动清除,必须人工显式复位。
解决步骤
清理磁盘空间确保所有数据节点磁盘使用率降至 85% 以下
删除过期的临时文件或迁移冷数据索引至独立存储卷。
解除全部被锁定的索引只读状态
执行集群全局设置更新:
curl -X PUT "localhost:9200/_all/_settings" -H 'Content-Type: application/json' -d'{
"index.blocks.read_only_allow_delete": null
}'
调高磁盘水位线保护阈值匹配大容量磁盘
在集群配置中优化百分比或绝对可用空间:
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'{
"persistent": {
"cluster.routing.allocation.disk.watermark.low": "85%",
"cluster.routing.allocation.disk.watermark.high": "90%",
"cluster.routing.allocation.disk.watermark.flood_stage": "95%"
}
}'
验证确认
重试应用写入操作:
文档写入恢复正常,集群健康状态从 RED/YELLOW 恢复为稳定的 GREEN。


