Chapter 13. Administration

This chapter covers replica set administration, including:

  • Performing maintenance on individual members

  • Configuring sets under a variety of circumstances

  • Getting information about and resizing your oplog

  • Doing some more exotic set configurations

  • Converting from master/slave to a replica set

Starting Members in Standalone Mode

A lot of maintenance tasks cannot be performed on secondaries (because they involve writes) and shouldn’t be performed on primaries because of the impact this could have on application performance. Thus, the following sections frequently mention starting up a server in standalone mode. This means restarting the member so that it is a standalone server, not a member of a replica set (temporarily).

To start up a member in standalone mode, first look at the command-line options used to start it. Suppose they look something like this:

> db.serverCmdLineOpts()
{
    "argv" : [ "mongod", "-f", "/var/lib/mongod.conf" ],
    "parsed" : {
        "replSet": "mySet",
        "port": "27017",
        "dbpath": "/var/lib/db"
    },
    "ok" : 1
}

To perform maintenance on this server we can restart it without the replSet option. This will allow us to read and write to it as a normal standalone mongod. We don’t want the other servers in the set to be able to contact it, so we’ll make it listen on a different port (so that the other members won’t be able to find it). Finally, we want to keep the dbpath the same, as we are presumably starting it up this way to manipulate the server’s data somehow. ...

Get MongoDB: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.