Elasticsearch cluster.routing.allocation.enable Setting

The cluster.routing.allocation.enable setting in Elasticsearch controls the allocation of shards across the cluster. It allows administrators to enable or disable various types of shard allocations, providing granular control over cluster operations.

  • Default value: all
  • Possible values:
    • all: Allows all types of shard allocations
    • primaries: Allows allocation of primary shards only
    • new_primaries: Allows allocation of primary shards for new indices only
    • none: No shard allocations are allowed

This setting is dynamic and can be updated at runtime. It's recommended to use this setting judiciously, especially during maintenance operations or when managing cluster load.

Example

To disable all shard allocations:

PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": "none"
  }
}

This might be useful when performing cluster maintenance, such as upgrading nodes, to prevent Elasticsearch from rebalancing shards during the operation.

Common Issues and Misuses

  • Forgetting to re-enable allocations after maintenance, leading to unbalanced clusters
  • Using none for extended periods, which can result in data availability issues
  • Misunderstanding the impact of primaries or new_primaries on existing indices

Do's and Don'ts

  • Do use this setting for controlled maintenance operations
  • Do monitor cluster health after changing this setting
  • Don't leave allocations disabled for longer than necessary
  • Don't use this as a long-term solution for cluster management issues
  • Do communicate changes to this setting with your team

Frequently Asked Questions

Q: How does changing cluster.routing.allocation.enable affect existing shards?
A: Changing this setting doesn't move existing shards immediately. It affects future allocation decisions. For example, setting it to none prevents any new allocations but doesn't move existing shards.

Q: Can I use this setting to perform a rolling restart of my cluster?
A: Yes, setting it to none before restarting nodes can prevent unnecessary shard movements during the restart process. Remember to re-enable allocations after the restart.

Q: What's the difference between primaries and new_primaries?
A: primaries allows allocation of all primary shards, while new_primaries only allows allocation of primary shards for newly created indices.

Q: How quickly does the cluster respond to changes in this setting?
A: The change is almost immediate. However, the effects on shard allocation may take some time to be visible, depending on the cluster's state and ongoing operations.

Q: Can this setting be used to isolate a node for decommissioning?
A: While it can help, it's better to use more specific settings like cluster.routing.allocation.exclude._name for node-specific exclusions.

Pulse - Elasticsearch Operations Done Right

Stop googling errors and staring at dashboards.

Free Trial

Subscribe to the Pulse Newsletter

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