记一次处理ES关于blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];问题的排查记录

2021-9-25 / 0评 / Java

昨天在重新启动很久以前做过logstash同步mysql数据到ES6.5索引的过程中,发现logstash报如下错误:

[2021-09-25T12:15:03,939][INFO ][logstash.outputs.elasticsearch] retrying failed action with response code: 403 ({"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"})

经过Google, 发现此问题是由于es数据存储磁盘剩余空间过少导致的. 官网对此的说明如下:
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 must be released manually once there is enough disk space available to allow indexing operations to continue.

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

根据官方说明,以上排查结果是ES将所有的index的blocks的read_only_allow_delete设置为true: 
ES实例服务出问题的原因在于es索引均被设置为只读只删模式. 才导致索引数据写入时失败.

问题原因:
半年前, 在本地单机ES服务机器上, 做过MySQL大量数据(涉及数据量达1千万量级)的读写操作, 当时磁盘空间被耗尽. 触发es的flood_stage, 全部索引被设置为只读只删.
但最近需要学习总结以前的数据处理过程, 重新启动logstash进行MySQL表数据同步到ES所有总, 导致logstash-plains.log一直此输出如上错误日志.

解决方法:
解决方法很简单, 仅需将对应es节点上的索引设置进行如下设置即可.
curl -XPUT -H 'Content-Type: application/json' http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": "false"}'

如果是线上服务发现此问题!!!
在线上进行某些操作时, 应对服务器资源占用有个粗略的估计或对服务器资源进行监控.
避免在执行某些操作时, 耗尽服务器资源而导致其他一些服务的异常。



本文共计 2657 字,感谢您的耐心浏览与评论。

声明:土豆丝不辣|版权所有,违者必究|如未注明,均为原创|转载请注明原文链接说明出处

0条回应:“记一次处理ES关于blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];问题的排查记录”