Database Reference
In-Depth Information
Understanding oplog
Oplog
is used to record all database changes in a collection of data.
An
oplog
(operations log) is a special capped collection that keeps a rolling record of all
the operations that modify the data stored in your databases (
http://docs.mongodb.org/
It is a fixed-size collection, and it will automatically overwrite old records when it reaches
the maximum size of the collection.
Oplog
is used in the replication procedure to facilitate
the process of replication between
primary
and
secondary
nodes.
The
secondary
nodes copy the primary's
oplog
and apply it, so all members will have
oplog
that saves the current state and recent history of the database.
The first time you add a replica set to the database, the server creates
oplog
with its de-
fault size. The size of
oplog
varies, and it depends on the operating system and machine
architecture. However, you can define and change the default size of
oplog
using the
oplogSize
property.
The following list shows you the default values for the
oplog
size based on different oper-
ating systems:
• For 64-bit Linux, Solaris, FreeBSD, and Windows systems, MongoDB allocates 5
percent of the available free disk space to
oplog
. If this amount is smaller than a
gigabyte, then MongoDB allocates 1 gigabyte of space.
• For 64-bit OS X systems, MongoDB allocates 183 megabytes of space to
oplog
.
• For 32-bit systems, MongoDB allocates about 48 megabytes of space to
oplog
To check the status of
oplog
and monitor the size of the log and collection, you can use
the following command and run it in the MongoDB shell:
db.printReplicationInfo()