Elasticsearch cluster.routing.allocation.exclude Setting

Pulse - Elasticsearch Operations Done Right

On this page

Example Common Issues and Misuses Do's and Don'ts Frequently Asked Questions

The cluster.routing.allocation.exclude setting in Elasticsearch is used to control shard allocation by excluding specific nodes from hosting shards based on arbitrary attributes. This setting allows cluster administrators to fine-tune shard distribution across nodes, enhancing cluster management and performance optimization.

  • Default value: Not set (empty)
  • Possible values: Comma-separated list of attribute-value pairs (e.g., _ip:10.0.0.1,rack:rack1)
  • Recommendations: Use sparingly and in conjunction with other allocation settings for balanced cluster management

This setting accepts various node attributes as filters, such as _ip, _name, _host, or any custom attribute defined on the nodes. When set, Elasticsearch will avoid allocating shards to nodes that match the specified criteria.

Example

To exclude shards from being allocated to nodes with IP addresses 10.0.0.1 and 10.0.0.2, you can use the cluster settings API:

PUT _cluster/settings
{
  "transient": {
    "cluster.routing.allocation.exclude._ip": "10.0.0.1,10.0.0.2"
  }
}

This change might be desired when performing maintenance on specific nodes or when you want to gradually decommission certain nodes from the cluster. The effect will be that Elasticsearch will attempt to relocate shards from the excluded nodes to other available nodes in the cluster.

Common Issues and Misuses

  • Overuse of exclusion rules can lead to unbalanced shard distribution
  • Excluding too many nodes may result in unallocated shards if there aren't enough eligible nodes
  • Forgetting to remove exclusion rules after maintenance can cause long-term allocation issues

Do's and Don'ts

  • Do use this setting for temporary maintenance or controlled node decommissioning
  • Do monitor cluster health and shard distribution after applying exclusion rules
  • Don't use this as a primary means of long-term cluster management
  • Don't exclude all nodes capable of hosting a particular shard, as it will result in unassigned shards
  • Do combine with other allocation settings for more granular control

Frequently Asked Questions

Q: How does cluster.routing.allocation.exclude differ from cluster.routing.allocation.enable?
A: While cluster.routing.allocation.exclude prevents specific nodes from receiving shards based on attributes, cluster.routing.allocation.enable controls the overall shard allocation process for the entire cluster or specific types of operations.

Q: Can I use wildcards in the exclude settings?
A: Yes, you can use wildcards. For example, _ip:10.0.0.* would exclude all nodes with IP addresses starting with 10.0.0.

Q: What happens to existing shards on a node when it's excluded?
A: Existing shards on an excluded node will be migrated to other eligible nodes in the cluster, assuming there are available nodes that can host them.

Q: How quickly does shard reallocation occur after setting an exclusion rule?
A: The speed of reallocation depends on various factors such as cluster load, shard sizes, and available resources. Elasticsearch will attempt to rebalance as quickly as possible while maintaining cluster stability.

Q: Can exclusion rules be set on a per-index basis?
A: No, cluster.routing.allocation.exclude is a cluster-wide setting. For index-specific allocation, you should use index-level allocation settings or index templates.

Subscribe to the Pulse Newsletter

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