# Configuring number of primary shards

**URL:** https://discuss.elastic.co/t/configuring-number-of-primary-shards/11839
**Category:** Elasticsearch
**Created:** [May 6, 2013, 6:00pm UTC](https://discuss.elastic.co/t/configuring-number-of-primary-shards/11839 "2013-05-06T18:00:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![vinod\_eligeti](https://avatars.discourse-cdn.com/v4/letter/v/c4cdca/32.png) [@vinod\_eligeti](https://discuss.elastic.co/u/vinod_eligeti)
#### Post date: [May 6, 2013, 6:00pm UTC](https://discuss.elastic.co/t/configuring-number-of-primary-shards/11839/1 "2013-05-06T18:00:55Z")

</div>

I was going through "To Infinity and Beyond" video where it mentions the  
number of primary shards ( but default is 5) cannot be changed however, the  
number of replica shards can?

I want to confirm whether that is true or not? Also what is the difference  
in operations done at the primary shard which is not done at the replica  
shard?

Thanks in advance

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)
#### Post date: [May 6, 2013, 6:18pm UTC](https://discuss.elastic.co/t/configuring-number-of-primary-shards/11839/2 "2013-05-06T18:18:57Z")

</div>

The number of shards cannot be changed once the index is created. However,  
the number of shards can be specified as any value you wish when the index  
is being created. I've created various indices with 1, 5 (default and  
explicit), 16, and 10 shards.

The number of replicas per shard can be set when the index is created and  
can be changed any time thereafter, even on a live in-use index. For one of  
my cluster-based tests, I create an index with 5 shards a 0 replicas, then  
bulk-load the initial set of 97 million records. About an hour later (when  
the load is completed), I dynamically set the number of replicas to 2 (so  
now each shard has 3 copies, one for each of my active nodes in the  
cluster). In a few minutes, the shards are all replicated. (Using version  
0.90.0 the initial load is about the same, the replicas take less time to  
all come up in the green, and the disk usage is dramatically smaller).

Somebody with internal knowledge can answer your last question. But from  
the outside looking in, the assignment of the primary shard is dynamic. For  
example, I loaded the 97 million records, and I watched the 5 shards  
distributed evenly (as much as possible) across the 3 machines: shards 0,  
1, 2, 3, and 4 were assigned to nodes A, B, C, A, and B, respectively.

When I bumped up the number of replicas to 2, those original shards  
remained as primary shards and the replicas filled out in about a minute or  
so.

Then I applied over 3 million updates (mix of index + delete actions).

But this weekend, our server closet suffered outages due to heat issues.  
One of the servers in the cluster never came back on-line, and the two  
remaining servers (nodes) now contained all of the primary shards plus one  
of the two replicas. When that 3rd server came back up this morning, the  
cluster took a minute or so and got all replicas verified and up-to-date on  
that node. But that node no longer contained any primary shards: It  
contains only replicas now.

Very cool. An unintended test of node failure and cluster recovery, and it  
went perfectly smoothly!

On Monday, May 6, 2013 2:00:55 PM UTC-4, vinod eligeti wrote:

> I was going through "To Infinity and Beyond" video where it mentions the  
> number of primary shards ( but default is 5) cannot be changed however, the  
> number of replica shards can?
> 
> I want to confirm whether that is true or not? Also what is the difference  
> in operations done at the primary shard which is not done at the replica  
> shard?
> 
> Thanks in advance

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![vinod\_eligeti](https://avatars.discourse-cdn.com/v4/letter/v/c4cdca/32.png) [@vinod\_eligeti](https://discuss.elastic.co/u/vinod_eligeti)
#### Post date: [May 8, 2013, 11:03pm UTC](https://discuss.elastic.co/t/configuring-number-of-primary-shards/11839/3 "2013-05-08T23:03:16Z")

</div>

Sorry for the late reply. Thanks appreciate your help.

On Mon, May 6, 2013 at 11:18 AM, InquiringMind [brian.from.fl@gmail.com](mailto:brian.from.fl@gmail.com)wrote:

> The number of shards cannot be changed once the index is created. However,  
> the number of shards can be specified as any value you wish when the index  
> is being created. I've created various indices with 1, 5 (default and  
> explicit), 16, and 10 shards.
> 
> The number of replicas per shard can be set when the index is created and  
> can be changed any time thereafter, even on a live in-use index. For one of  
> my cluster-based tests, I create an index with 5 shards a 0 replicas, then  
> bulk-load the initial set of 97 million records. About an hour later (when  
> the load is completed), I dynamically set the number of replicas to 2 (so  
> now each shard has 3 copies, one for each of my active nodes in the  
> cluster). In a few minutes, the shards are all replicated. (Using version  
> 0.90.0 the initial load is about the same, the replicas take less time to  
> all come up in the green, and the disk usage is dramatically smaller).
> 
> Somebody with internal knowledge can answer your last question. But from  
> the outside looking in, the assignment of the primary shard is dynamic. For  
> example, I loaded the 97 million records, and I watched the 5 shards  
> distributed evenly (as much as possible) across the 3 machines: shards 0,  
> 1, 2, 3, and 4 were assigned to nodes A, B, C, A, and B, respectively.
> 
> When I bumped up the number of replicas to 2, those original shards  
> remained as primary shards and the replicas filled out in about a minute or  
> so.
> 
> Then I applied over 3 million updates (mix of index + delete actions).
> 
> But this weekend, our server closet suffered outages due to heat issues.  
> One of the servers in the cluster never came back on-line, and the two  
> remaining servers (nodes) now contained all of the primary shards plus one  
> of the two replicas. When that 3rd server came back up this morning, the  
> cluster took a minute or so and got all replicas verified and up-to-date on  
> that node. But that node no longer contained any primary shards: It  
> contains only replicas now.
> 
> Very cool. An unintended test of node failure and cluster recovery, and it  
> went perfectly smoothly!
> 
> On Monday, May 6, 2013 2:00:55 PM UTC-4, vinod eligeti wrote:
> 
> > I was going through "To Infinity and Beyond" video where it mentions the  
> > number of primary shards ( but default is 5) cannot be changed however, the  
> > number of replica shards can?
> > 
> > I want to confirm whether that is true or not? Also what is the  
> > difference in operations done at the primary shard which is not done at the  
> > replica shard?
> > 
> > Thanks in advance
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/mhIULO9Vo5I/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/mhIULO9Vo5I/unsubscribe?hl=en-US)  
> .  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 2:37am UTC](https://discuss.elastic.co/t/configuring-number-of-primary-shards/11839/4 "2017-07-06T02:37:28Z")

</div>


