Databases Reference
In-Depth Information
Administration
In this section, we'll introduce some administration concepts that are specific to
replication.
Diagnostics
MongoDB includes a couple of useful administrative helpers for inspecting the status
of replication. When connected to the master, use the db.printReplicationInfo
function:
> db.printReplicationInfo();
configured oplog size: 10.48576MB
log length start to end: 34secs (0.01hrs)
oplog first event time: Tue Mar 30 2010 16:42:57 GMT-0400 (EDT)
oplog last event time: Tue Mar 30 2010 16:43:31 GMT-0400 (EDT)
now: Tue Mar 30 2010 16:43:37 GMT-0400 (EDT)
This gives information about the size of the oplog and the date ranges of operations
contained in the oplog. In this example, the oplog is about 10MB and is only able to
fit about 30 seconds of operations. This is almost certainly a case where we should
increase the size of the oplog (see the next section). We want the log length to be at
least as long as the time it takes to do a full resync—that way, we don't run into a case
where a slave is already out of sync by the time its initial sync (or resync) is finished.
The log length is computed by taking the time difference between the
first and last operation in the oplog. If the server has just started, then
the first operation will be relatively recent. In that case, the log length
will be small, even though the oplog probably still has free space avail-
able. The log length is a more useful metric for servers that have been
operational long enough for the oplog to “roll over.”
We can also get some information when connected to the slave, using the
db.printSlaveReplicationInfo function:
> db.printSlaveReplicationInfo();
source: localhost:27017
syncedTo: Tue Mar 30 2010 16:44:01 GMT-0400 (EDT)
= 12secs ago (0hrs)
This will show a list of sources for the slave, each with information about how far behind
the master it is. In this case, we are only 12 seconds behind the master.
Changing the Oplog Size
If we find that the oplog size needs to be changed, the simplest way to do so is to stop
the master, delete the files for the local database, and restart with a new setting for
 
Search WWH ::




Custom Search