背景:
Springboot正常运行中,应用的某个功能突然无法使用,应用日志报错信息:
org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=cluster_block_exception, reason=blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];]
排查发现是由于应用所在服务器磁盘使用达到了98%,导致ES服务触发保护机制,将索引设置为了只读模式。
解决:
-
清理磁盘文件,腾出空间
-
关闭ES的索引只读模式
curl -X PUT "localhost:9200/_all/_settings" -H 'Content-Type: application/json' -d
{
"index.blocks.read_only_allow_delete": null
}
- 验证
GET /_settings
index.blocks.read_only_allow_delete : false
- 调整预警上限
PUT /_cluster/settings
{
"persistent": {
"cluster.routing.allocation.disk.watermark.low": "85%",
"cluster.routing.allocation.disk.watermark.high": "90%",
"cluster.routing.allocation.disk.watermark.flood_stage": "95%"
}
}