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, 即仅允许只读只删, 不允许新增.

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

# 查看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"}'

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值