1. 程式人生 > 其它 >ES報錯 [FORBIDDEN/12/index read-only / allow delete (api)] - read only elasticsearch indices

ES報錯 [FORBIDDEN/12/index read-only / allow delete (api)] - read only elasticsearch indices

技術標籤:【ElasticSearch】elasticsearchjavaes資料庫大資料

我司主要使用ElasticSearch作為NOSQL使用,今天報錯,檢視錯誤日誌如下,ElasticSearch進入“只讀”模式,節點無法更改

Config: Error 403 Forbidden: blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];: [cluster_block_exception] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];

問題排查

檢視 Elasticsearch 官方文件, 原文如下:


Elasticsearch considers the available disk space on a node before deciding whether to allocate new shards to that node or to actively relocate shards away from that node.

Elasticsearch 在決定是否分配新分片給該節點,或對該節點重新定位分片之前,會先判斷該節點儲存空間是否足夠,如果說你的使用磁碟空間已經超過 95%,ES 會自動將索引 index 置為 read-only 狀態。

但是!!!!! 檢視Elasticsearch 儲存目錄和日誌目錄磁碟空間都是夠夠的,

解決問題

之前Elasticsearch 磁碟滿過,處於只讀狀態,或者網路波動問題,處於只讀狀態的索引,只能被查詢或者刪除。而 ES 還不會自動將索引狀態切換回來,就需要我們手動切換了:

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

將127.0.0.1:9200提交成你的ip就可以

歡迎關注微信公眾號

在這裡插入圖片描述

**