The index.routing.allocation.exclude._host
setting in Elasticsearch is used to control shard allocation by excluding specific hosts from storing shards of a particular index. This setting allows for fine-grained control over where index shards are allocated within the cluster.
- Default value: Not set (no hosts excluded)
- Possible values: Comma-separated list of hostnames or IP addresses
- Recommendations: Use this setting judiciously to balance load or isolate specific indices from certain hosts
This setting is part of the index-level shard allocation settings. It works in conjunction with other allocation settings to provide granular control over shard placement in the cluster.
Example Usage
To exclude shards of an index named "my_index" from being allocated to hosts "host1" and "host2":
PUT /my_index/_settings
{
"index.routing.allocation.exclude._host": "host1,host2"
}
You might want to change this setting to:
- Perform maintenance on specific hosts without affecting the entire cluster
- Isolate resource-intensive indices to dedicated hardware
- Implement data locality requirements
The effect of this change will be that Elasticsearch will move existing shards from the excluded hosts and prevent new shards from being allocated to these hosts for the specified index.
Common Issues and Misuses
- Over-exclusion leading to unbalanced cluster
- Forgetting to reset the setting after maintenance, causing long-term imbalance
- Conflicting with other allocation settings, resulting in unexpected shard distributions
Do's and Don'ts
- Do use this setting for temporary maintenance or specific performance tuning
- Do monitor cluster health after making changes to ensure proper shard distribution
- Don't exclude too many hosts, which could lead to allocation issues
- Don't forget to remove or update the setting once it's no longer needed
- Do consider using this in combination with include and require settings for more precise control
Frequently Asked Questions
Q: Can I use wildcards in the host values?
A: Yes, you can use wildcards like host*.domain.com
to match multiple hosts with similar names.
Q: What happens if I exclude all available hosts?
A: If all available hosts are excluded, Elasticsearch will not be able to allocate shards for the index, potentially leading to a red cluster status.
Q: Does this setting affect existing shard allocations?
A: Yes, when you apply this setting, Elasticsearch will attempt to move existing shards off the excluded hosts to comply with the new allocation rules.
Q: How does this setting interact with other allocation settings?
A: This setting is combined with other allocation settings using AND logic. All conditions must be satisfied for a shard to be allocated to a node.
Q: Can I use this setting to implement a hot-warm architecture?
A: While it's possible, it's generally better to use node attributes and the index.routing.allocation.include
settings for implementing hot-warm architectures more explicitly and flexibly.