3

Is that even possible? How else could I restore the data from a slaveDelay-Secondary? The only way I can think of is to shut down all the other running members of the replica set and copy the slaveDelay-Secondary data folder to the other members and restart the replica set. I just couldn't find anything in the MongoDB documentation. Maybe I'm missing something essential here and the solution is too obvious.

Jk1
  • 10,266
  • 9
  • 49
  • 63

2 Answers2

4

You have several options :

  • use mongoexport/mongodump and manually reinject your data whereever you want (not recommended)
  • Tweak your priority to make your secondary primary. ( not recommended)
  • read the related documentation page (recommended)

Basically : you just have to shutdown all other memebers of your replicaset and then apply the procedure described on the quoted page.

kamaradclimber
  • 2,461
  • 1
  • 25
  • 44
0

To make the slave to sync you can either copy data files by stopping writes to db or you can try mongodump and mongorestore methods.Kindly check this link for reference.

You can force your secondary replica to be a primary by following the below steps:

Step 1: Connect to member and check the current configuration

rs.conf()

Step 2: Save the current configuration to another variable.

x = rs.conf()

Step 3: Select the id,host and port of the member that is to be made as primary.

x.members = [{"_id":1,"host" : "localhost.localdomain:27071"}]

Step 4: Reconfigure them by force.

rs.reconfig(x, {force:true})

Now the desired member will be promoted as the primary.

JERRY
  • 6,524
  • 1
  • 22
  • 32