Elasticsearch index.routing.allocation.include._host_ip Setting

The index.routing.allocation.include._host_ip setting in Elasticsearch controls shard allocation based on the IP addresses of the nodes in the cluster. This setting allows you to specify which nodes should host shards of a particular index based on their IP addresses.

  • Default value: Not set
  • Possible values: Comma-separated list of IP addresses or IP ranges
  • Recommendation: Use this setting when you need to control shard allocation based on network topology or to ensure data locality in specific network segments.

This setting is part of the broader shard allocation filtering mechanism in Elasticsearch. It works in conjunction with other allocation settings to provide fine-grained control over where shards are placed within the cluster.

Example

To allocate shards of an index only to nodes with specific IP addresses:

PUT /my-index/_settings
{
  "index.routing.allocation.include._host_ip": "192.168.1.1,192.168.1.2"
}

This change would cause Elasticsearch to allocate shards of my-index only to nodes with the IP addresses 192.168.1.1 or 192.168.1.2. You might want to do this to ensure data locality or to segregate certain indices to specific network segments for security or performance reasons.

Common Issues and Misuses

  • Overuse of this setting can lead to unbalanced shard distribution and potential cluster instability.
  • If the specified IP addresses don't match any nodes, it can prevent shard allocation entirely for the index.
  • Changing this setting on an existing index can trigger significant shard relocation, potentially impacting cluster performance.

Do's and Don'ts

  • Do use this setting in combination with other allocation settings for more precise control.
  • Do consider the impact on cluster balance when using this setting.
  • Don't rely solely on IP-based allocation for critical data placement decisions.
  • Don't frequently change this setting, as it can cause unnecessary shard migrations.

Frequently Asked Questions

Q: Can I use wildcards or CIDR notation with this setting?
A: Yes, you can use IP ranges in CIDR notation (e.g., "192.168.1.0/24") or wildcards (e.g., "192.168.1.*") to specify a range of IP addresses.

Q: How does this setting interact with other allocation settings?
A: This setting is combined with other allocation settings using AND logic. For a shard to be allocated to a node, all active allocation rules must be satisfied.

Q: What happens if I remove an IP address from this setting?
A: Shards on nodes with the removed IP address will become eligible for relocation to other nodes that match the updated setting.

Q: Can this setting be used to allocate shards across different data centers?
A: Yes, if your data centers have distinct IP ranges, you can use this setting to control shard allocation across different data centers.

Q: Is there a performance impact when using this setting?
A: The setting itself doesn't impact performance, but the resulting shard allocations might affect query performance if not balanced properly across the cluster.

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.