# Primary and replica set question?

**URL:** <https://discuss.elastic.co/t/primary-and-replica-set-question/10408>\
**Category:** Elasticsearch\
**Created:** [January 18, 2013, 12:08pm UTC](https://discuss.elastic.co/t/primary-and-replica-set-question/10408 "2013-01-18T12:08:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Janusz\_Dalecki](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@Janusz\_Dalecki](https://discuss.elastic.co/u/Janusz_Dalecki)\
**Post date:** [January 18, 2013, 12:08pm UTC](https://discuss.elastic.co/t/primary-and-replica-set-question/10408/1 "2013-01-18T12:08:41Z")

</div>

Hi,

I have run three nodes (on one laptop) and expected that by default only  
one replica is going to be created (5 shards and one replica right?).

However when I run plugin head GUI I can see two replicas for shard 0 (“\*Dragon  
Man” as primary, \*_Frost, Deacon – replica, Stygorr - replica_) – why?

Am I missing something?

Regards,

Janusz

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [January 18, 2013, 12:13pm UTC](https://discuss.elastic.co/t/primary-and-replica-set-question/10408/2 "2013-01-18T12:13:44Z")

</div>

On Fri, 2013-01-18 at 04:08 -0800, JD wrote:

> Hi,
> 
> I have run three nodes (on one laptop) and expected that by default  
> only one replica is going to be created (5 shards and one replica  
> right?).
> 
> However when I run plugin head GUI I can see two replicas for shard 0  
> (“Dragon Man” as primary, Frost, Deacon – replica, Stygorr - replica)  
> – why?
> 
> Am I missing something?

I think so. If you have number\_of\_replicas set to 1, then you will have  
a max of 1 replica per shard.

Have a look at the output of this request to get a better idea of what  
is happening:

curl -XGET '[http://127.0.0.1:9200/\_cluster/state?pretty=1](http://127.0.0.1:9200/_cluster/state?pretty=1)'

It may be that it is moving a shard from one node to another, which is  
why it appears twice

clint

--

---

<div class="post-metadata">

**Author:** ![Janusz\_Dalecki](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@Janusz\_Dalecki](https://discuss.elastic.co/u/Janusz_Dalecki)\
**Post date:** [January 18, 2013, 12:54pm UTC](https://discuss.elastic.co/t/primary-and-replica-set-question/10408/3 "2013-01-18T12:54:30Z")

</div>

Hi,  
That is even more strage

On Friday, January 18, 2013 11:08:41 PM UTC+11, JD wrote:

> Hi,
> 
> I have run three nodes (on one laptop) and expected that by default only  
> one replica is going to be created (5 shards and one replica right?).
> 
> However when I run plugin head GUI I can see two replicas for shard 0 (“\*Dragon  
> Man” as primary, \*_Frost, Deacon – replica, Stygorr - replica_) – why?
> 
> Am I missing something?
> 
> Regards,
> 
> Janusz

--

---

<div class="post-metadata">

**Author:** ![Janusz\_Dalecki](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@Janusz\_Dalecki](https://discuss.elastic.co/u/Janusz_Dalecki)\
**Post date:** [January 18, 2013, 12:55pm UTC](https://discuss.elastic.co/t/primary-and-replica-set-question/10408/4 "2013-01-18T12:55:24Z")

</div>

OK. I have three nodes and two of them are marked as primary (bold border  
under plugin head Web GUI) – is that correct?

Regards,

Janusz

On Friday, January 18, 2013 11:08:41 PM UTC+11, JD wrote:

> Hi,
> 
> I have run three nodes (on one laptop) and expected that by default only  
> one replica is going to be created (5 shards and one replica right?).
> 
> However when I run plugin head GUI I can see two replicas for shard 0 (“\*Dragon  
> Man” as primary, \*_Frost, Deacon – replica, Stygorr - replica_) – why?
> 
> Am I missing something?
> 
> Regards,
> 
> Janusz

--

---

<div class="post-metadata">

**Author:** ![Janusz\_Dalecki](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@Janusz\_Dalecki](https://discuss.elastic.co/u/Janusz_Dalecki)\
**Post date:** [January 18, 2013, 2:07pm UTC](https://discuss.elastic.co/t/primary-and-replica-set-question/10408/5 "2013-01-18T14:07:18Z")

</div>

Sorry. Just clarification.  
Can I have few primary shards on a few nodes?  
Regards,  
Janusz

On Friday, January 18, 2013 11:08:41 PM UTC+11, JD wrote:

> Hi,
> 
> I have run three nodes (on one laptop) and expected that by default only  
> one replica is going to be created (5 shards and one replica right?).
> 
> However when I run plugin head GUI I can see two replicas for shard 0 (“\*Dragon  
> Man” as primary, \*_Frost, Deacon – replica, Stygorr - replica_) – why?
> 
> Am I missing something?
> 
> Regards,
> 
> Janusz

--

---

<div class="post-metadata">

**Author:** ![Janusz\_Dalecki](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@Janusz\_Dalecki](https://discuss.elastic.co/u/Janusz_Dalecki)\
**Post date:** [January 18, 2013, 2:17pm UTC](https://discuss.elastic.co/t/primary-and-replica-set-question/10408/6 "2013-01-18T14:17:39Z")

</div>

Sorry. I have been looking across different indexes - my appology.  
All good,  
Regards,  
Janusz

On Friday, January 18, 2013 11:08:41 PM UTC+11, JD wrote:

> Hi,
> 
> I have run three nodes (on one laptop) and expected that by default only  
> one replica is going to be created (5 shards and one replica right?).
> 
> However when I run plugin head GUI I can see two replicas for shard 0 (“\*Dragon  
> Man” as primary, \*_Frost, Deacon – replica, Stygorr - replica_) – why?
> 
> Am I missing something?
> 
> Regards,
> 
> Janusz

--

---

<div class="post-metadata">

**Author:** ![drewr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewr/32/7803_2.png) [@drewr](https://discuss.elastic.co/u/drewr)\
**Post date:** [January 28, 2013, 6:09pm UTC](https://discuss.elastic.co/t/primary-and-replica-set-question/10408/7 "2013-01-28T18:09:38Z")

</div>

JD wrote:

> Sorry. I have been looking across different indexes - my appology.

We have a tool called es2unix[1] which has a shards command for quick  
visualization of this type of data. Example from my laptop:

% curl -O [download.elasticsearch.org/es2unix/es](http://download.elasticsearch.org/es2unix/es); chmod +x es  
% ./es shards  
wiki 0 p STARTED 1160290 7.2gb 7776371641 127.0.0.1 Feline  
wiki 0 r STARTED 1160290 7.2gb 7776371602 127.0.0.1 Amphibius  
wiki 0 r STARTED 1160290 7.2gb 7776371602 127.0.0.1 Jenkins, Abner  
wiki 1 r STARTED 1159509 7.5gb 8116295811 127.0.0.1 Feline  
wiki 1 p STARTED 1159509 7.5gb 8116295811 127.0.0.1 Amphibius  
wiki 1 r STARTED 1159509 7.5gb 8116295811 127.0.0.1 Jenkins, Abner  
foo 0 r STARTED 0 79b 79 127.0.0.1 Amphibius  
foo 0 p STARTED 0 99b 99 127.0.0.1 Jenkins, Abner  
foo 1 p STARTED 0 99b 99 127.0.0.1 Feline  
foo 1 r STARTED 0 79b 79 127.0.0.1 Amphibius

You can quickly tell that all the shards belong to the wiki index.  
If you just want the primaries that belong to foo:

% ./es shards fo | fgrep ' p '  
foo 0 p STARTED 0 99b 99 127.0.0.1 Jenkins, Abner  
foo 1 p STARTED 0 99b 99 127.0.0.1 Feline

Sometimes this is nicer than a graphical tool, especially over ssh.

-Drew

Footnotes:  
[1] [GitHub - elastic/es2unix: Command-line ES](https://github.com/elasticsearch/es2unix)

--

---

<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:54am UTC](https://discuss.elastic.co/t/primary-and-replica-set-question/10408/8 "2017-07-06T02:54:21Z")

</div>


