TransportError(403, u'cluster_block_exception', u'被阻止: [FORBIDDEN/12/index 只读/允许删除 (api)];')

TransportError(403, u'cluster_block_exception', u'blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];')

当我尝试在 elasticsearch 中存储任何内容时,出现错误提示:

TransportError(403, u'cluster_block_exception', u'blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];')

我已经在我的索引中插入了大约 2 亿个文档。但我不知道为什么会发生此错误。 我试过:

curl -u elastic:changeme -XPUT 'localhost:9200/_cluster/settings' -H 'Content-Type: application/json' -d '{"persistent":{"cluster.blocks.read_only":false}}'

如此处所述:

结果是:

{"acknowledged":true,"persistent":{"cluster":{"blocks":{"read_only":"false"}}},"transient":{}}

但没有任何改变。我该怎么办?

尝试GET yourindex/_settings,这将显示您的索引设置。如果 read_only_allow_deletetrue,则尝试:

PUT /<yourindex>/_settings
{
  "index.blocks.read_only_allow_delete": null
}

我的问题已解决。

请参阅 es config guide 了解更多详情。

curl 命令是

curl -X PUT "localhost:9200/twitter/_settings?pretty" -H 'Content-Type: application/json' -d '
{
  "index.blocks.read_only_allow_delete": null
}'

问题可能是磁盘 space 问题,尽管我清理了很多 space 我的磁盘,但我还是遇到了这个问题,所以,最后我删除了数据文件夹并且它起作用了:sudo rm -rf /usr/share/elasticsearch/data/

上个月我遇到了同样的问题,你可以在你的 Kibana Dev Tools 上试试这个代码

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

希望对你有帮助

当我的磁盘 space 已满时,我遇到了同样的问题,

请看我做的步骤

1-增加磁盘space

2-更新索引只读模式,见如下curl请求

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

我自己也遇到了这个问题,稍后再进行标记 - 我完成了以下步骤。 1) 删除旧索引以立即释放 space - 这使我获得了大约 23% 的空闲。 2) 更新索引只读模式。

我仍然遇到同样的问题。我检查了 Dev Console 以查看哪些内容可能仍被锁定,而 none 是。重新启动集群并遇到同样的问题。

最后,在索引管理下,我选择了具有 ILM 生命周期问题的索引,并选择重新应用 ILM 步骤。必须这样做几次才能将它们全部清除,但确实如此。

这解决了问题; PUT _settings { "index": { "blocks": { "read_only_allow_delete": "false" }
}

发生这种情况是因为弹性搜索的默认水​​印磁盘使用。通常是磁盘大小的 95%。

This happens when Elasticsearch thinks the disk is running low on space so it puts itself into read-only mode.

By default Elasticsearch's decision is based on the percentage of disk space that's free, so on big disks this can happen even if you have many gigabytes of free space.

The flood stage watermark is 95% by default, so on a 1TB drive you need at least 50GB of free space or Elasticsearch will put itself into read-only mode.

For docs about the flood stage watermark see https://www.elastic.co/guide/en/elasticsearch/reference/6.2/disk-allocator.html.

部分引用自

一个解决方案是完全禁用它(我发现它在我的本地和 CI 设置中很有用)。要做到这一点 运行 2 个命令:

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'