0Pricing
Elasticsearch & Full Text Search Systems · Lektion

Shard-Zuweisung und Neuausbalancierung

Verstehen Sie, wie Elasticsearch entscheidet, wo Shards liegen, wie Allocation Awareness Replikate auf Hardware verteilt und wie Sie die Neuausbalancierung während Skalierung und Wartung steuern.

Shard-Zuweisung und Neuausbalancierung ist eine kostenlose Elasticsearch & Full Text Search Systems-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Elasticsearch & Full Text Search Systems-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Elasticsearch & Full Text Search Systems-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Where Do Shards Go?

When you create an index or add a node, Elasticsearch must decide which node holds each shard. This process is shard allocation, and keeping it balanced is key to a healthy, performant cluster.

The Allocation Process

The master node runs allocation deciders for every unassigned shard. They check disk space, shard count, awareness rules, and filters before placing a shard. Failing any decider keeps the shard UNASSIGNED.

Primary vs Replica Placement

A replica is never allocated to the same node as its primary. This guarantees that losing one node cannot take out both copies of the same data. With one replica you survive any single-node failure.

Watching Allocation

Use the _cat/shards API to see where each shard sits and its state. STARTED means active; RELOCATING means it is moving.

GET _cat/shards?v

Explaining a Stuck Shard

When a shard will not allocate, the _cluster/allocation/explain API tells you exactly which decider blocked it and why. This is the first stop for debugging a yellow or red cluster.

GET _cluster/allocation/explain
{
  "index": "my_index",
  "shard": 0,
  "primary": false
}

Allocation Awareness

Allocation awareness spreads copies across physical boundaries like racks or availability zones. You tag nodes with custom attributes and tell the cluster to be aware of them.

cluster.routing.allocation.awareness.attributes: zone

Forced Awareness

Forced awareness goes further: it refuses to over-allocate replicas to surviving zones if a zone goes down, preventing one zone from holding all copies. This protects capacity planning during outages.

cluster.routing.allocation.awareness.force.zone.values: zone1,zone2

Shard Filtering

You can pin or exclude an index from specific nodes using allocation filters. This is handy for hot/warm architectures where older indices migrate to cheaper hardware.

PUT my_index/_settings
{
  "index.routing.allocation.require.box_type": "warm"
}

Rebalancing

After nodes join or leave, the cluster rebalances to even out shard counts. This is automatic but generates network and disk I/O, so it should be controlled during sensitive operations.

Pausing Allocation

Before a rolling restart, disable allocation so the cluster does not waste effort relocating shards from a node you are about to bring back. Re-enable it afterward.

PUT _cluster/settings
{
  "transient": {
    "cluster.routing.allocation.enable": "primaries"
  }
}

Throttling

Limit concurrent recoveries with cluster.routing.allocation.node_concurrent_recoveries and bandwidth with indices.recovery.max_bytes_per_sec to keep rebalancing from starving live queries.

Quick Check

Test your understanding of shard allocation.

Recap

You learned how shards are placed and balanced:

  • Allocation deciders choose shard locations; replicas avoid their primary's node.
  • Debug stuck shards with allocation/explain.
  • Allocation awareness and forced awareness spread copies across zones.
  • Use allocation filters for hot/warm tiers and disable allocation during rolling restarts.

Häufig gestellte Fragen

Ist die Lektion „Shard-Zuweisung und Neuausbalancierung“ kostenlos?

Ja — der vollständige Text von „Shard-Zuweisung und Neuausbalancierung“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Elasticsearch & Full Text Search Systems-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Elasticsearch & Full Text Search Systems-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Shard-Zuweisung und Neuausbalancierung“?

Verstehen Sie, wie Elasticsearch entscheidet, wo Shards liegen, wie Allocation Awareness Replikate auf Hardware verteilt und wie Sie die Neuausbalancierung während Skalierung und Wartung steuern. Du übst Elasticsearch & Full Text Search Systems mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Elasticsearch & Full Text Search Systems zu starten?

Keine Vorkenntnisse erforderlich. Elasticsearch & Full Text Search Systems auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Shard-Zuweisung und Neuausbalancierung“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Elasticsearch & Full Text Search Systems-Lektion Code schreiben und ausführen?

Ja. Jede Elasticsearch & Full Text Search Systems-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Sharding und Replikate erklärt
  2. Clusterzustand und Monitoring
  3. Knotenrollen und Architektur
  4. Shard-Zuweisung und Neuausbalancierung
← Zurück zu Elasticsearch & Full Text Search Systems