The index.routing.allocation.exclude._id
setting in Elasticsearch is used to control shard allocation by excluding specific nodes based on their node IDs. This setting allows you to prevent an index's shards from being allocated to certain nodes in the cluster.
- Default value: Not set (empty)
- Possible values: A comma-separated list of node IDs
- Recommendations: Use this setting judiciously to fine-tune shard allocation when specific nodes should not host shards of a particular index.
This setting is part of the index-level shard allocation settings and works in conjunction with other allocation rules. It's particularly useful when you need to exclude specific nodes from hosting shards of an index, perhaps due to hardware constraints or administrative purposes.
Example
To set the index.routing.allocation.exclude._id
for an existing index:
PUT /my-index/_settings
{
"index.routing.allocation.exclude._id": "node1,node2"
}
In this example, shards of the my-index
index will not be allocated to nodes with IDs node1
or node2
. This could be useful if these nodes are scheduled for maintenance or have resource constraints.
Common Issues or Misuses
- Over-exclusion: Excluding too many nodes can lead to unallocated shards if there aren't enough eligible nodes remaining.
- Forgetting to reset: After temporary exclusions (e.g., for maintenance), users might forget to remove the exclusion, leading to suboptimal shard distribution.
Do's and Don'ts
- Do use this setting for temporary exclusions during maintenance or to manage resource allocation.
- Do monitor shard allocation after applying this setting to ensure proper distribution.
- Don't exclude all available nodes for an index, as this will result in unallocated shards.
- Don't use this as a long-term solution for managing node roles; instead, consider using dedicated node types.
Frequently Asked Questions
Q: Can I use wildcards in the node ID list?
A: No, the index.routing.allocation.exclude._id
setting requires specific node IDs. Wildcards are not supported for this particular setting.
Q: How does this setting interact with other allocation settings?
A: This setting is applied in conjunction with other allocation rules. Elasticsearch will try to satisfy all allocation rules, including exclusions, when determining shard placement.
Q: What happens if I exclude all available nodes?
A: If all available nodes are excluded, the shards will remain unallocated, and the index may become unavailable or read-only.
Q: Can I use this setting to move shards off a node immediately?
A: While this setting will prevent new allocations to the excluded nodes, it doesn't force immediate relocation. To move shards quickly, you may need to use the cluster reroute API in addition to this setting.
Q: Is there a limit to how many node IDs I can exclude?
A: There's no hard limit, but excluding too many nodes can impact cluster health and shard allocation. It's best to use this setting sparingly and monitor its effects closely.