Eytan Avisror
Eytan Avisror

Reputation: 2970

How to add additional primary shards to Elasticsearch cluster?

I have a cluster containing 7 nodes, I've recently noticed that we are only using 5 primary shards, meaning that per index - we are only utilizing 5 nodes out of 7. I would like to add two additional primary shards for newly created indices.

I've added the following to elasticsearch.yml and restarted the cluster:

index.number_of_shards: 7 index.number_of_replicas: 0

However, it's been a few days and a few new indices since - and I still see its sharding to 5 pieces.. can anyone explain why? am I missing some additional configuration here?

Thanks!

Upvotes: 3

Views: 4546

Answers (2)

Andrei Stefan
Andrei Stefan

Reputation: 52368

You cannot add primary shards without creating a new index and re-indexing all your data.

You can add replicas, but not primaries without reindexing. For a zero-downtime re-indexing scenario, check this link.

Upvotes: 1

dimzak
dimzak

Reputation: 2571

You have to reindex affected index. As I imagine there is only 1 index in the cluster. Number of shards can not change automatically in an existing index.

This relative question might help and this question if you do not want any downtime, it works with aliases and basically 2 indexes- 1 before resharding and 1 afterwards and then you switch aliases to point in wherever index you want

Upvotes: 2

Related Questions