赞
踩
当对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, 即仅允许只读只删, 不允许新增.
可以通过以下方法查询索引状态:
- # 查看ES当前索引的配置
- 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"}'
但需要注意的是,我们还要将磁盘进行清理,否则该错误还会重复发生。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。