0

I have a basic 3 member MongoDB replication set. 1 x Primary 2 x Secondary

A = Primary B = Secondary C = Secondary

The Mongod service on the Primary stopped, and as expected, one of the Secondaries took over as Primary.

I restarted Mongod on the former Primary, and it became a Secondary, so I now have:

A = Secondary B = Primary C = Secondary

Should A automatically become the Primary again, or is this something I have to do manually?

I haven't set any priorities on the nodes.

1 Answer 1

1

That's what priorities are there for, if you feel that a certain machine should be Primary if it's up, you give it a higher priority than the others. Priorities have other uses, like making "hidden" secondaries, and a few other control situations.

4
  • OK, so if no priorities are set, the RS won't automatically promote the former Primary back to Primary after a Primary failure? Apr 16, 2014 at 16:55
  • Not in my experience, mongodb isn't running comparisons on the nodes, so it can't "decide" which is the better machine.. that's your job :)
    – NickW
    Apr 16, 2014 at 16:58
  • OK, that worked. Thanks. Note for others: you must add the priority values and run the reconfig command from the node that is acting as Primary. Apr 16, 2014 at 17:02
  • 1
    Primary failover is a disruptive process with a brief period in which there will be no primary available and writes will fail. Given that it is beneficial to have as few failovers as possible. Of course if there is a reason to prefer a given host to be primary (better specs for example) then priorities are definitely the way to control. Apr 17, 2014 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .