0
0
Elasticsearchquery~20 mins

Shard allocation awareness in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Shard Allocation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the effect of this shard allocation awareness setting?
Given this Elasticsearch cluster setting, what will be the output of GET _cluster/settings?include_defaults=true regarding awareness attributes?
Elasticsearch
PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.awareness.attributes": "rack_id"
  }
}
AThe cluster will distribute shards evenly across nodes with different rack_id values.
BThe cluster will allocate all shards only to nodes with the same rack_id.
CThe cluster will ignore rack_id and allocate shards randomly.
DThe cluster will disable shard allocation awareness.
Attempts:
2 left
💡 Hint
Think about what shard allocation awareness does with the specified attribute.
🧠 Conceptual
intermediate
2:00remaining
What happens if a node lacks the awareness attribute?
In an Elasticsearch cluster with shard allocation awareness set to zone, what happens if a node does not have the zone attribute configured?
AThe node will receive only replica shards.
BThe node will receive shards normally, ignoring awareness settings.
CThe node will not receive any shards because it lacks the awareness attribute.
DThe cluster will fail to allocate shards and throw an error.
Attempts:
2 left
💡 Hint
Consider how awareness attributes control shard distribution.
Predict Output
advanced
2:00remaining
What is the output of this shard allocation command?
What will be the output of this command in an Elasticsearch cluster with awareness attribute rack set, when trying to allocate a shard to a node without the rack attribute?
Elasticsearch
POST /_cluster/reroute
{
  "commands": [
    {
      "allocate": {
        "index": "my_index",
        "shard": 0,
        "node": "node_without_rack",
        "allow_primary": true
      }
    }
  ]
}
A{"acknowledged": false, "error": "allocation failed due to awareness attribute mismatch"}
B{"acknowledged": true, "explanation": "shard allocated successfully"}
C{"acknowledged": false, "error": "node not found"}
D{"acknowledged": true, "explanation": "shard allocated ignoring awareness"}
Attempts:
2 left
💡 Hint
Think about how awareness attributes restrict shard allocation.
🧠 Conceptual
advanced
2:00remaining
How does forced awareness affect shard allocation?
If cluster.routing.allocation.awareness.force.zone.values is set to ["zone1", "zone2"], what is the effect on shard allocation?
AShards will be allocated randomly without considering zones.
BShards will be allocated to any zone, but prefer zone1 and zone2.
CShards will be allocated only if all zones have at least one node available.
DShards will only be allocated to nodes in zone1 and zone2, ignoring other zones.
Attempts:
2 left
💡 Hint
Forced awareness restricts allocation to specified attribute values.
Predict Output
expert
3:00remaining
What is the number of shards allocated after these settings?
Given a cluster with 3 nodes having rack attributes: node1 (rack: a), node2 (rack: b), node3 (rack: a), and an index with 3 primary shards and 1 replica each, with awareness attribute set to rack, how many shards will be allocated on node3?
Elasticsearch
PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.awareness.attributes": "rack"
  }
}

PUT my_index
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  }
}
A0 shards
B1 shard
C2 shards
D3 shards
Attempts:
2 left
💡 Hint
Consider how replicas are allocated across different rack values.