Skip to content

Mongodb Dba Homework 3.2

There is this question here:

How to force a mongod to become primary in a replica set?

But it was not the answer I was looking for.

and there is the question below, which could be related but it is not the same.

How to force a delayed member to become primary in case of failure in mongodb

and this question which is nearly a duplicate, but deals with version 2.6.11 and mine is version 3.0 and 3.2. Plus I don't want to use force : 1 unless I need to.

Force a Member to Become Primary in mongodb

I have been struggling to put in practice the majority described in the answer there, maybe with an example or clarification, therefore this question.

I had my replication working fine, 3 nodes, node1 is the primary.

when I run the following command

I get this result:

what happened is that I had to stop node1 (jpb01275:37001) and the node2 became the primary. When I started node1 again, I wanted it to become the primary again.

what I did is

logged into node2 and node3 run the following command on then, one after another:

and the node1 came back as a primary.

I also tried the following on node1, but it did not work for me.

what is the correct, safest way to bring back node1 and set it as a primary for this replication?


I have to move a 200GB MongoDB from one server to another (both Windows 2016 OS). During this operation, it is assumed that the accompanying program will be offline, so no need to worry about inconsistent data, but I need to minimize the downtime. Diskspace is not an issue, but downtime is. I've tried testing it with mongodump and mongorestore, but that took almost 20 hours to complete, which seems pretty ridiculous. I'm looking at a couple other options:

  1. Use copydb
  2. Take a snapshot of the disk and/or copy the db folder directly to the new server and point the installation to that by changing the path in the .conf file.

I'm guessing #2 would be fastest if it will work, but I haven't found any real confirmation that it works on a Windows platform. Has anyone successfully done this? If so, is it as simple as I described? As mentioned, MongoDB and its accompanying program can be turned off completely for this operation.

Alternatively, can anyone give me a ballpark figure on how long copydb takes versus a mongodump/mongorestore operation?