Elasticsearch 索引變成只讀


 

1、業務報錯

org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]

初步判斷索引變成只讀了。

 

2、查找原因

Elasticsearch在決定是向該節點分配新的碎片還是主動將碎片從該節點移開之前,先考慮節點上的可用磁盤空間。

查找官網 有個關於變成只讀索引的參數:

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 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM