Elasticsearch index.routing.allocation.exclude Setting

The index.routing.allocation.exclude setting in Elasticsearch is used to control index-level shard allocation by excluding specific nodes or node attributes from hosting shards of a particular index.

  • Default value: Not set (no exclusions)
  • Possible values: Comma-separated list of node names, IP addresses, or attribute-value pairs
  • Recommendations: Use sparingly and in conjunction with other allocation settings for balanced cluster management

This setting allows you to specify which nodes should not receive shards for a particular index. It's part of the broader shard allocation filtering mechanism in Elasticsearch, providing fine-grained control over where index data is stored within your cluster.

Example

To exclude shards of an index named "my_index" from nodes with the attribute "disk_type" set to "hdd":

PUT /my_index/_settings
{
  "index.routing.allocation.exclude._disk_type": "hdd"
}

This change might be desired when you want to ensure that a specific index is only allocated to nodes with faster SSD storage for improved performance.

Common Issues and Misuses

  • Over-exclusion leading to unallocated shards
  • Conflicting with other allocation settings, causing unexpected behavior
  • Forgetting to update the setting when cluster topology changes

Do's and Don'ts

Do's:

  • Use in combination with include and require settings for balanced allocation
  • Regularly review and update exclusion rules as your cluster evolves
  • Test changes in a non-production environment first

Don'ts:

  • Don't exclude too many nodes, which could prevent proper shard allocation
  • Avoid using this setting as a primary means of data isolation (use dedicated clusters instead for strict isolation requirements)
  • Don't set exclusions without considering the impact on cluster balance and performance

Frequently Asked Questions

Q: Can I use wildcards in the index.routing.allocation.exclude setting?
A: Yes, you can use wildcards for node names or IP addresses, but be cautious as this can lead to unintended exclusions.

Q: How does this setting interact with index.routing.allocation.include?
A: The exclude setting takes precedence over include. If a node matches both an include and exclude rule, it will be excluded.

Q: Will changing this setting cause immediate shard relocation?
A: Yes, Elasticsearch will attempt to relocate shards to comply with the new setting as soon as it's applied, subject to other allocation rules and cluster state.

Q: Can I use this setting to move all shards off a node for maintenance?
A: While possible, it's generally better to use the cluster-level allocation exclude setting for temporary node exclusions during maintenance.

Q: How can I verify that the exclusion is working as expected?
A: You can check the cluster health, shard allocation, and node stats APIs to confirm that shards are allocated according to your exclusion rules.

Pulse - Elasticsearch Operations Done Right

Pulse can solve your Elasticsearch issues

Subscribe to the Pulse Newsletter

Get early access to new Pulse features, insightful blogs & exclusive events , webinars, and workshops.

We use cookies to provide an optimized user experience and understand our traffic. To learn more, read our use of cookies; otherwise, please choose 'Accept Cookies' to continue using our website.