Total number of shards for an index on a single node exceeded
editTotal number of shards for an index on a single node exceeded
editElasticsearch tries to take advantage of all the available resources by distributing data (index shards) among nodes in the cluster.
Users might want to influence this data distribution by configuring the index.routing.allocation.total_shards_per_node
index setting to a custom value (for e.g. 1
in case of a highly trafficked index).
Various configurations limiting how many shards an index can have located on one node
can lead to shards being unassigned due to the cluster not having enough nodes to
satisfy the index configuration.
In order to fix this follow the next steps:
In order to get the shards assigned we’ll need to increase the number of shards
that can be collocated on a node.
We’ll achieve this by inspecting the configuration for the index.routing.allocation.total_shards_per_node
index setting and increasing the configured value for the
indices that have shards unassigned.
Use Kibana
- Log in to the Elastic Cloud console.
-
On the Elasticsearch Service panel, click the name of your deployment.
If the name of your deployment is disabled your Kibana instances might be unhealthy, in which case please contact Elastic Support. If your deployment doesn’t include Kibana, all you need to do is enable it first.
-
Open your deployment’s side navigation menu (placed under the Elastic logo in the upper left corner) and go to Dev Tools > Console.
-
Inspect the
index.routing.allocation.total_shards_per_node
index setting for the index with unassigned shards:GET /my-index-000001/_settings/index.routing.allocation.total_shards_per_node?flat_settings
The response will look like this:
-
Increase the value for the total number of shards that can be assigned on one node to a higher value:
The new value for the
total_shards_per_node
configuration for themy-index-000001
index is increased from the previous value of1
to2
. Thetotal_shards_per_node
configuration can also be set to-1
, which represents no upper bound with regards to how many shards of the same index can reside on one node.
In order to get the shards assigned you can add more nodes to your Elasticsearch cluster and assing the index’s target tier node role to the new nodes.
To inspect which tier is an index targeting for assignment, use the get index setting
API to retrieve the configured value for the index.routing.allocation.include._tier_preference
setting:
GET /my-index-000001/_settings/index.routing.allocation.include._tier_preference?flat_settings
The response will look like this:
{ "my-index-000001": { "settings": { "index.routing.allocation.include._tier_preference": "data_warm,data_hot" } } }
Represents a comma separated list of data tier node roles this index is allowed
to be allocated on, the first one in the list being the one with the higher priority
i.e. the tier the index is targeting.
e.g. in this example the tier preference is |
Alternatively, if adding more nodes to the Elasticsearch cluster is not desired,
inspecting the configuration for the index.routing.allocation.total_shards_per_node
index setting and increasing the configured value will
allow more shards to be assigned on the same node.
-
Inspect the
index.routing.allocation.total_shards_per_node
index setting for the index with unassigned shards:GET /my-index-000001/_settings/index.routing.allocation.total_shards_per_node?flat_settings
The response will look like this:
-
Increase the total number of shards that can be assigned on one node or reset the value to unbounded (
-1
):PUT /my-index-000001/_settings { "index" : { "routing.allocation.total_shards_per_node" : -1 } }