Is there anyway to reconfigure a replica set in the event the primary as well as a majority of the servers are down ? For example if data center 1 goes does, a procedure can be run to reconfigure and set a new primary with the remaining servers?

I keep getting this "Command '$eval' failed: not master (response: { "note" : "from execCommand", "ok" : 0.0, "errmsg" : "not master" })"

We only have 2 data centers. (I we had 3 i realize this would solve my problem, but we don't. ) I was thinking about running a reconfigure on a 5 member replica set every time the fail over happens and changing the host of the arbiter from one data center to another so that the active data center will always have the arbiter, but I can't do that if 3 of the 5 members of the replica set aren't available...because not new primary will ever be set.

Any suggestions?

  • 1
    What command are you running? As per the docs you link to, you can force a reconfig by passing {force : true} as the second argument in rs.reconfig(). The first argument would be a document detailing the new, reduced set of replica set members. Sep 5, 2014 at 21:02
  • I'm trying to do it in the .NET driver with the EVAL method on the MongoDatabase object. I tried passing in a simple javascript method to attempt anything to be returned, but even with just a simple function (that doesn't actually do anything to the database), it just throws an exception with the error "not master". Is there something other than eval that I can use to accomplish this?
    – Stephen
    Sep 8, 2014 at 13:34

1 Answer 1


Yes, you can do this, and in fact with just 2 data centers you really have no other choice. Essentially, whenever you do not have a primary you can still do a reconfig but you must pass in {force:true} to make it happen on a non-primary node.

This is listed in the docs for the rs.reconfig() command and in detail (with examples) as part of a tutorial which describes exactly what needs to be done in the scenario you described:


If you are interested, I cover this and other availability issues in the (free) M202: Advanced Deployment and Operations course on MongoDB University

  • Thanks, Adam. I'll definitely look into that class. Does it change anything if I'm trying to do this in a .NET web service. I'm trying to use the MongoDatabase.Eval() method of the mongo .NET driver, but even when I pass in a simple javascript method, I get an exception saying it failed because it's not the master. Is there another method I can use besides eval that doesn't require it to be executed on primary?
    – Stephen
    Sep 8, 2014 at 13:39
  • There is an example of the .Net command document here: groups.google.com/forum/#!msg/mongodb-user/OkU59UWAsCY/… and you should be able to pass in the force:true at that point. Similarly, you may need to set slaveOK or equivalent to get it to work (collectionSettings.SlaveOk = true) - sorry, .NET is not my thing. If you can't figure it out, then a quick question on StackOverflow with .NET and MongoDB tags should get it sorted for you pretty quickly :)
    – Adam C
    Sep 8, 2014 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.