O'Reilly logo

MongoDB: The Definitive Guide, 3rd Edition by Kristina Chodorow, Shannon Bradshaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Administration

This chapter covers replica set administration, including:

  • Techniques for 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 argument. Suppose it looks 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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required