如何禁用 ElasticSearch 磁盘配额/水位线

在默认配置中,当磁盘总体使用超过 90%(即由 ElasticSearch 或其他应用程序使用)时,ElasticSearch 将不再分配更多磁盘空间。

你可以使用以下命令将水位线设置得非常低

set-elasticsearch-watermarks.sh
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
  "transient": {
    "cluster.routing.allocation.disk.watermark.low": "30mb",
    "cluster.routing.allocation.disk.watermark.high": "20mb",
    "cluster.routing.allocation.disk.watermark.flood_stage": "10mb",
    "cluster.info.update.interval": "1m"
  }
}
'

执行此操作后,如果你之前已经超过水位线,你可能需要解锁集群以进行写访问:

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

请参见如何修复 ElasticSearch [FORBIDDEN/12/index read-only / allow delete (api)]了解更多详情。

我不建议将值设置为零(即低于 10 兆字节),因为使用每个字节的可用磁盘空间可能会导致系统问题,因为更重要的应用程序将无法再正确分配磁盘空间。

要查看当前磁盘使用情况,使用

elasticsearch-allocation.sh
curl -XGET "http://localhost:9200/_cat/allocation?v&pretty"

请参见如何查看和解释 ElasticSearch 集群的磁盘空间使用情况了解更多详情。


Check out similar posts by category: Databases, ElasticSearch