1. Nodes and roles #
Who does what.
Roles #
# elasticsearch.yml d'un nœud data hot
node.name: es-hot-01
node.roles: [ data_hot, data_content, ingest ]
node.attr.zone: eu-west-3aThe elected master node maintains the cluster state: list of nodes, mappings, location of each shard. A quorum of eligible nodes is required: with 3 eligible nodes, the cluster tolerates the loss of only one.
Common mistake: Two master-eligible nodes protect against nothing: losing one loses the quorum. Use 3 nodes (or 2 + a voting_only node).2. Shards and replicas #
How data is distributed.
Principle #
- An index is split into primary shards (fixed at creation); each one is a Lucene index.
- Each primary has replicas (changeable on the fly): high availability and read capacity.
- A replica is never placed on the same node as its primary.
- Green status: everything is allocated; yellow: replicas are missing; red: primaries are missing.
3. Allocation and failures #
What happens when a node goes down.
Allocation #
- The node stops responding: the master removes it from the cluster.
- The replicas of its primaries are promoted to primaries: no data lost, the cluster turns yellow.
- After
index.unassigned.node_left.delayed_timeout(1 minute by default), new replicas are rebuilt on the remaining nodes. - When the node comes back, Elasticsearch rebalances the shards.
GET _cluster/health
GET _cat/shards?v&h=index,shard,prirep,state,node,unassigned.reason
GET _cluster/allocation/explain
# répartir les répliques entre zones de disponibilité
PUT _cluster/settings
{ "persistent": { "cluster.routing.allocation.awareness.attributes": "zone" } }Good practice: With zone-based allocation awareness, a replica and its primary are always in two different zones: losing an entire zone loses no data.
