Allocation awareness allocates some replicas (#104800)

The docs for forced awareness indicate that no replicas will be assigned
until all zones are available, which is definitely undesirable and also
not the actual behaviour. This commit fixes the wording to match what
really happens.

Closes #104777
This commit is contained in:
David Turner 2024-01-29 08:13:06 +00:00 committed by GitHub
parent 99e72b02ba
commit 88e497069a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -75,27 +75,32 @@ enable forced awareness.
[[forced-awareness]] [[forced-awareness]]
===== Forced awareness ===== Forced awareness
By default, if one location fails, Elasticsearch assigns all of the missing By default, if one location fails, {es} spreads its shards across the remaining
replica shards to the remaining locations. While you might have sufficient locations. This might be undesirable if the cluster does not have sufficient
resources across all locations to host your primary and replica shards, a single resources to host all its shards when one location is missing.
location might be unable to host *ALL* of the shards.
To prevent a single location from being overloaded in the event of a failure, To prevent the remaining locations from being overloaded in the event of a
you can set `cluster.routing.allocation.awareness.force` so no replicas are whole-location failure, specify the attribute values that should exist with the
allocated until nodes are available in another location. `cluster.routing.allocation.awareness.force.*` settings. This will mean that
{es} will prefer to leave some replicas unassigned in the event of a
whole-location failure instead of overloading the nodes in the remaining
locations.
For example, if you have an awareness attribute called `zone` and configure nodes For example, if you have an awareness attribute called `zone` and configure
in `zone1` and `zone2`, you can use forced awareness to prevent Elasticsearch nodes in `zone1` and `zone2`, you can use forced awareness to make {es} leave
from allocating replicas if only one zone is available: half of your shard copies unassigned if only one zone is available:
[source,yaml] [source,yaml]
------------------------------------------------------------------- -------------------------------------------------------------------
cluster.routing.allocation.awareness.attributes: zone cluster.routing.allocation.awareness.attributes: zone
cluster.routing.allocation.awareness.force.zone.values: zone1,zone2 <1> cluster.routing.allocation.awareness.force.zone.values: zone1,zone2 <1>
------------------------------------------------------------------- -------------------------------------------------------------------
<1> Specify all possible values for the awareness attribute. <1> Specify all possible `zone` attribute values.
With this example configuration, if you start two nodes with `node.attr.zone` set With this example configuration, if you have two nodes with `node.attr.zone`
to `zone1` and create an index with 5 shards and 1 replica, Elasticsearch creates set to `zone1` and an index with `number_of_replicas` set to `1`, {es}
the index and allocates the 5 primary shards but no replicas. Replicas are allocates all the primary shards but none of the replicas. It will assign the
only allocated once nodes with `node.attr.zone` set to `zone2` are available. replica shards once nodes with a different value for `node.attr.zone` join the
cluster. In contrast, if you do not configure forced awareness, {es} will
allocate all primaries and replicas to the two nodes even though they are in
the same zone.