1、業務報錯
org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]
初步判斷索引變成只讀了。
2、查找原因
cluster.routing.allocation.disk.watermark.flood_stage
原文:
Controls the flood stage watermark. It defaults to 95%, meaning that Elasticsearch enforces a read-only index block(index.blocks.read_only_allow_delete)on every index that has one or more shards allocated on the node that has at least one disk exceeding the flood stage. This is a last resort to prevent nodes from running out of disk space. The index block is automatically released once the disk utilization falls below the high watermark.
翻譯:
控制洪泛水位線。默認為95%,這意味着Elasticsearch在每個索引上強制執行只讀索引塊(“index.blocks.read_only_allow_delete”),該索引在至少有一個磁盤超過洪泛階段的節點上分配了一個或多個碎片。這是防止節點耗盡磁盤空間的最后手段。一旦磁盤利用率低於高水位線,索引塊就會自動釋放。
3、解決方案
以上是可以在 elasticsearch.yml 配置文件中配置的設置,也可以使用 cluster-update-settings API 在活動集群上動態更新設置。
1)先對磁盤進行擴容,或者刪除不用的索引釋放空間
2)重置該只讀索引塊
PUT /_all/_settings { "index.blocks.read_only_allow_delete": null }
