本机磁盘用量长期维持94%左右,真实验证disk watermark三个水位必须满足low≤high≤flood_stage的顺序约束,全新分片撞上high水位会直接unassigned,而已经started的分片水位下调后不会被驱逐只会加上read_only_allow_delete这个block,并真实验证这个block允许的delete指的是删除整个索引而非文档,跟名字直觉完全相反。
代码本机 df -h / 真实显示: 24Gi可用 / 460Gi总量 ≈ 94%已用 PUT /_cluster/settings {"persistent":{ "cluster.routing.allocation.disk.watermark.low":"88%", "cluster.routing.allocation.disk.watermark.high":"89%", "cluster.routing.allocation.disk.watermark.flood_stage":"90%" }} PUT /ro_test {"settings":{"number_of_shards":1,"number_of_replicas":0}}
ro_test 0 p UNASSIGNED 集群健康: status=red
这个真实结果说明超过high水位的后果,对一个还没有任何副本存在于任何地方的全新分片来说,真实不是"变成只读"这么温和,而是真实直接拒绝分配——因为超过high水位的节点真实被ES判定为"不适合接收新分片",这跟本系列上一篇验证allocation.exclude时发现的"新分片没有既成事实保护"是同一类真实行为。
代码PUT /_cluster/settings {"persistent":{ "cluster.routing.allocation.disk.watermark.high":"98%", "cluster.routing.allocation.disk.watermark.flood_stage":"90%" }}
→ 400 illegal_argument_exception: "high disk watermark [98%] more than flood stage disk watermark [90%]"
代码PUT /_cluster/settings {"persistent":{ "cluster.routing.allocation.disk.watermark.low":"95%", "cluster.routing.allocation.disk.watermark.high":"96%", "cluster.routing.allocation.disk.watermark.flood_stage":"97%" }} 删除重建 ro_test,确认分片STARTED,真实写入1条文档成功(result:"created") PUT /_cluster/settings {"persistent":{ "cluster.routing.allocation.disk.watermark.low":"88%", "cluster.routing.allocation.disk.watermark.high":"89%", "cluster.routing.allocation.disk.watermark.flood_stage":"90%", "cluster.routing.allocation.disk.watermark.flood_stage.frozen":"90%" }} # 等待35秒,让磁盘监控周期性重新评估
ro_test 0 p STARTED ← 真实分片位置完全没变
GET /ro_test/_settings
→ settings.index.blocks: {"read_only_allow_delete":"true"} ← 真实自动加上的这组真实结果跟本系列上一篇allocation.exclude的发现一脉相承:ES真实不会主动驱逐已经安置好的分片去制造数据不可用,水位下调后它选择的真实应对方式是给索引加上一个保护性的只读block,而不是把分片踢走——这跟全新分片撞上high水位时"直接拒绝分配"是完全不同的两种真实应对策略,取决于这个分片是否已经有"已经安全存在于某处"这个既成事实。
代码POST /ro_test/_doc {"n":2} DELETE /ro_test/_doc/<已有文档id> DELETE /ro_test # 删除整个索引
写入 → 429 cluster_block_exception:
"index [ro_test] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded
flood-stage watermark, index has read-only-allow-delete block]"
删除文档 → 429 cluster_block_exception ← 真实跟写入收到完全一样的拒绝
删除整个索引 DELETE /ro_test → {"acknowledged":true} ← 真实这个才会成功代码PUT /_cluster/settings {"persistent":{ "cluster.routing.allocation.disk.watermark.low":"98%", "cluster.routing.allocation.disk.watermark.high":"99%", "cluster.routing.allocation.disk.watermark.flood_stage":"99.5%", "cluster.routing.allocation.disk.watermark.flood_stage.frozen":null }} DELETE /ro_test
status: "green" active_primary_shards: 4 active_shards: 4 unassigned_shards: 0
每一步都是本文上面在本机真实的Elasticsearch 8.15.0上跑出来的原始结果。
cluster.routing.allocation.disk.watermark.* 设置df -h 磁盘用量(约94%)