Navigation
This version of the documentation is archived and no longer supported. To learn how to upgrade your version of MongoDB Ops Manager, refer to the upgrade documentation.
You were redirected from a different version of the documentation. Click here to go back.

Seed a New Secondary from Backup Restore

Overview

When a natural synchronization of a new secondary host costs too much time or resources, seeding a secondary from an Ops Manager Backup restore is a faster better alternative. Seeding also does not impact an active MongoDB instance to retrieve data.

Prerequisites

To seed a secondary from a backup restore file, you must have:

  • A backup restore file.
  • The seedSecondary.sh script included in the backup restore file.

When you run the seedSecondary.sh script as part of this tutorial, you must provide the replica set’s oplog size, in gigabytes. If you do not have the size, see the section titled “Check the Size of the Oplog” on the Troubleshoot Replica Sets page of the MongoDB manual.

Considerations

An Ops Manager backup stores all database files in a single directory. If you run MongoDB with the directoryPerDb option, then after restore you must redistribute the files to the different databases. Ops Manager Backup does not provide restoration artifacts that use the directoryPerDb option.

The seedSecondary.sh file will not be in the backup restore if you have blacklisted dbs or collections or have resynced your backup after the snapshot (or for config servers). In these cases, including the script would cause an inconsistent secondary. In the case of a blacklist, your secondary would not include some collections which would cause problems for your deployment.

Seeding a new secondary from a backup restore requires an oplog window on the current primary that spans back to the snapshot’s timestamp.

Procedure

1

Remove the broken secondary from your replica set.

rs.remove("SECONDARYHOST:SECONDARYPORT")
2

Login to the server on which to create the new secondary.

3

Bring up new node as a standalone.

tar -xvf backup-restore-name.tar.gz
mv backup-restore-name data
mongod --port <alternate-port> --dbpath /data

Where ALTERNATEPORT is not the usual port your secondary runs on.

4

Run seedSecondary.sh script to create oplog collection and seed with correct timestamp.

The seedSecondary.sh script re-creates the oplog collection and seeds it with correct timestamp.

To run the script, issue the following command at the system prompt, where <mongod-port> is the port of the mongod instance and <oplog-size-in-gigabytes> is the size of the replica set’s oplog:

./seedSecondary.sh <mongod-port> <oplog-size-in-gigabytes>
5

Shut down the new secondary on the alternate port.

6

Start up the new secondary.

mongod --port <secondary-port> --dbpath /data  --replSet REPLICASETNAME
7

Add the new secondary to the replica set on the primary host.

rs.add("<secondary-host>:<secondary-port>")