Let’s first take a look at the error message in the console.
elasticsearch.exceptions.RequestError:
RequestError(400, 'validation_exception', 'Validation Failed: 1:
this action would add [2] shards,
but this cluster currently has [1000]/[1000] maximum normal shards open;')
The error message you’re seeing indicates that the maximum number of shards allowed in your Elasticsearch cluster has been reached. By default, Elasticsearch has a limit of 1000 shards per cluster.
To fix this error, you have a few options:
-
Increase the maximum number of shards: You can increase the maximum number of shards allowed in your Elasticsearch cluster by modifying the
cluster.max_shards_per_node
setting in your Elasticsearch configuration file (elasticsearch.yml
). Set it to a higher value that suits your needs. After making the change, you’ll need to restart Elasticsearch for the new setting to take effect. Or to modify thecluster.max_shards_per_node
setting in Elasticsearch using the API, you can make aPUT
request to the_cluster/settings
endpoint. Here’s an example using thecurl
command:curl -XPUT -H "Content-Type: application/json" -d '{ "persistent": { "cluster.max_shards_per_node": {{new_max_shards}} } }' http://localhost:9200/_cluster/settings
Replace
{{new_max_shards}}
with the desired new value forcluster.max_shards_per_node
.
Make sure to adjust the URL (http://localhost:9200
) if your Elasticsearch cluster is running on a different host or port.
Note that modifying the cluster settings requires administrative privileges. Also, keep in mind that changing this setting will affect the entire cluster, so consider the impact on performance and resource usage before making any changes. -
Reduce the number of shards: If you have control over the index settings, you can reduce the number of shards for your indices. You can either merge smaller indices into larger ones or reduce the number of shards when creating new indices. This will help free up shard slots in your cluster.
-
Delete unnecessary indices: If you have any unnecessary indices that are no longer needed, you can delete them to free up shard slots. However, be cautious when deleting indices as it will permanently remove the data.文章来源:https://www.toymoban.com/news/detail-779161.html
Remember to consider the performance and resource limitations of your Elasticsearch cluster when making changes to the shard configuration.文章来源地址https://www.toymoban.com/news/detail-779161.html
到了这里,关于How to fix the limit of 1000 shards per cluster in ES的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!