Elasticsearch index.routing.allocation.exclude._host_ip Setting

The index.routing.allocation.exclude._host_ip setting in Elasticsearch is used to control shard allocation by excluding specific host IP addresses. This setting allows you to prevent shards of an index from being allocated to nodes with certain IP addresses.

  • Default value: Not set
  • Possible values: Comma-separated list of IP addresses or IP ranges
  • Recommendations: Use this setting judiciously to ensure balanced shard distribution and avoid overloading specific nodes

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 a particular index based on their IP addresses.

Example

To set the index.routing.allocation.exclude._host_ip for an existing index using the cluster settings API:

PUT /my-index/_settings
{
  "index.routing.allocation.exclude._host_ip": "10.0.0.1,10.0.0.2"
}

This example excludes nodes with IP addresses 10.0.0.1 and 10.0.0.2 from hosting shards of the "my-index" index. You might want to change this setting if you need to perform maintenance on specific nodes or if you want to ensure that certain indices are not allocated to nodes in a particular network segment.

Common Issues and Misuses

  • Overuse of exclusion rules can lead to unbalanced cluster shard distribution
  • Excluding too many nodes may result in unassigned shards if there are not enough eligible nodes
  • Forgetting to remove exclusion rules after they're no longer needed can cause long-term allocation issues

Do's and Don'ts

Do's:

  • Use this setting for temporary exclusions during maintenance or upgrades
  • Combine with other allocation settings for fine-grained control
  • Monitor shard distribution after applying exclusion rules

Don'ts:

  • Don't exclude all available nodes for an index
  • Avoid using this setting as a permanent solution for node selection
  • Don't forget to remove or update the setting when network configurations change

Frequently Asked Questions

Q: Can I use wildcards in the IP addresses for this setting?
A: Yes, you can use wildcards. For example, "192.168.1.*" would exclude all nodes with IP addresses in the 192.168.1.0/24 subnet.

Q: How does this setting interact with other allocation settings?
A: This setting is applied in combination with other allocation rules. Elasticsearch evaluates all allocation rules to determine the final shard placement.

Q: Will changing this setting cause immediate shard relocation?
A: Yes, changing this setting can trigger shard relocation if the current allocation violates the new rule. However, the actual relocation depends on other cluster settings and conditions.

Q: Can I use this setting to allocate shards to specific nodes instead of excluding them?
A: For allocating to specific nodes, you should use the index.routing.allocation.include._host_ip setting instead. The exclude setting is specifically for preventing allocation to certain nodes.

Q: How can I check which nodes are currently excluded for an index?
A: You can use the Index Settings API to retrieve the current settings for an index, including the index.routing.allocation.exclude._host_ip value.

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.