The index.routing.allocation.exclude._publish_ip
setting in Elasticsearch is used to control shard allocation based on the publish address of nodes. It allows you to exclude specific IP addresses or ranges from hosting shards of a particular index.
- Default value: Not set
- Possible values: Comma-separated list of IP addresses or IP ranges
- Recommendations: Use this setting judiciously to fine-tune shard allocation for specific indices when you need to exclude certain nodes based on their publish addresses.
This setting is part of the index-level shard allocation filtering mechanism. It works in conjunction with other allocation settings to provide granular control over where index shards are placed within the cluster.
Example Usage
To set the index.routing.allocation.exclude._publish_ip
for an existing index:
PUT /my-index/_settings
{
"index.routing.allocation.exclude._publish_ip": "192.168.1.1,192.168.1.2"
}
This example excludes nodes with publish IP addresses 192.168.1.1 and 192.168.1.2 from hosting shards of the "my-index" index.
Reasons for changing this setting might include:
- Isolating certain indices from specific nodes for performance or security reasons
- Preparing for node maintenance by moving shards away from specific nodes
Effects of the change:
- Elasticsearch will attempt to relocate existing shards on the excluded nodes to other eligible nodes
- New shards for the index will not be allocated to the excluded nodes
Common Issues or Misuses
- Overuse of exclusion rules can lead to unbalanced shard distribution
- Excluding too many nodes may result in unallocated shards if there are not enough eligible nodes
- Forgetting to remove exclusions after maintenance can cause long-term allocation imbalances
Do's and Don'ts
Do's:
- Use this setting for temporary exclusions during maintenance
- Combine with other allocation settings for comprehensive shard management
- Monitor shard distribution after applying exclusions
Don'ts:
- Don't use this setting as a primary means of long-term cluster organization
- Avoid excluding too many nodes, which could lead to allocation failures
- Don't forget to remove exclusions when they're no longer needed
Frequently Asked Questions
Q: How does index.routing.allocation.exclude._publish_ip differ from node.attr based exclusions?
A: While node attributes allow for custom-defined exclusions, the _publish_ip exclusion specifically targets the node's publish address, which is useful for network-based allocation strategies.
Q: Can I use wildcards or CIDR notation with this setting?
A: Yes, you can use wildcards (e.g., 192.168.1.*) and CIDR notation (e.g., 192.168.1.0/24) to specify IP ranges for exclusion.
Q: What happens if all available nodes are excluded for an index?
A: If all nodes are excluded, the index shards will remain unallocated until the exclusion is removed or new eligible nodes are added to the cluster.
Q: Is it possible to exclude nodes based on both publish and bind addresses?
A: While index.routing.allocation.exclude._publish_ip targets the publish address, you can use index.routing.allocation.exclude._ip to target the bind address, allowing for exclusions based on both.
Q: How quickly does shard reallocation occur after setting an exclusion?
A: Shard reallocation begins immediately, but the speed depends on factors like cluster load, shard size, and available resources. You can monitor progress using the cluster health and allocation explanation APIs.