当前位置:   article > 正文

ES 索引只读问题解决_es索引变成只读了

es索引变成只读了

        当对ES进行写操作是出现blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]错误时,表明当前索引变成了只读状态。

原因:

经过查阅, 发现此问题是由于es数据存储磁盘剩余空间过少导致索引被设置为了只读状态的. 官网对此的说明如下:

cluster.routing.allocation.disk.watermark.flood_stage 

(Dynamic) Controls the flood stage watermark, which defaults to 95%. 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, and that has at least one disk exceeding the flood stage. This setting is a last resort to prevent nodes from running out of disk space. The index block is automatically released when the disk utilization falls below the high watermark. Similarly to the low and high watermark values, it can alternatively be set to a ratio value, e.g., 0.95, or an absolute byte value.

即es存在一种flood_stage的机制. 默认的磁盘空间设置为95%, 当磁盘占用超过此值阈值时, 将会触发flood_stage机制, ES强制将各索引index.blocks.read_only_allow_delete设置为true, 即仅允许只读只删, 不允许新增.

可以通过以下方法查询索引状态:

  1. # 查看ES当前索引的配置
  2. GET index_name/_settings?pretty

解决方法:
解决方法很简单, 仅需将对应es节点上的索引设置进行如下设置即可.

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

但需要注意的是,我们还要将磁盘进行清理,否则该错误还会重复发生。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/199786
推荐阅读
相关标签
  

闽ICP备14008679号