- Reference >
- MongoDB Package Components >
mongooplog
mongooplog
¶
New in version 2.2.
Synopsis¶
mongooplog
is a simple tool that polls operations from
the replication oplog of a remote server, and applies
them to the local server. This capability supports certain classes of
real-time migrations that require that the source server remain online
and in operation throughout the migration process.
Typically this command will take the following form:
This command copies oplog entries from the mongod
instance
running on the host mongodb0.example.net
and duplicates
operations to the host mongodb1.example.net
. If you do not need
to keep the --from
host running during
the migration, consider using mongodump
and
mongorestore
or another backup operation, which may be better suited to
your operation.
Note
If the mongod
instance specified by the --from
argument is running with authentication
, then
mongooplog
will not be able to copy oplog entries.
See also
mongodump
, mongorestore
,
MongoDB Backup Methods, Replica Set Oplog.
Options¶
-
mongooplog
¶
-
--help
¶
Returns a basic help and usage text.
-
--verbose
,
-v
¶
Increases the amount of internal reporting returned on the command line. Increase the verbosity with the
-v
form by including the option multiple times, (e.g.-vvvvv
.)
-
--version
¶
Returns the version of the
mongooplog
utility.
-
--host
<hostname><:port>
,
-h
¶
Specifies a resolvable hostname for the
mongod
instance to whichmongooplog
will apply oplog operations retrieved from the serve specified by the--from
option.mongooplog
assumes that all targetmongod
instances are accessible by way of port27017
. You may, optionally, declare an alternate port number as part of the hostname argument.You can always connect directly to a single
mongod
instance by specifying the host and port number directly.To connect to a replica set, you can specify the replica set seed name, and a seed list of set members, in the following format:
-
--port
¶
Specifies the port number of the
mongod
instance wheremongooplog
will apply oplog entries. Only specify this option if the MongoDB instance that you wish to connect to is not running on the standard port. (i.e.27017
) You may also specify a port number using the--host
command.
-
--ipv6
¶
Enables IPv6 support that allows
mongooplog
to connect to the MongoDB instance using an IPv6 network. All MongoDB programs and processes, includingmongooplog
, disable IPv6 support by default.
-
--ssl
¶
New in version 2.4: MongoDB added support for SSL connections to
mongod
instances in mongooplog.Note
SSL support in mongooplog is not compiled into the default distribution of MongoDB. See Connect to MongoDB with SSL for more information on SSL and MongoDB.
Additionally, mongooplog does not support connections to
mongod
instances that require client certificate validation.Allows
mongooplog
to connect tomongod
instance over an SSL connection.
-
--username
<username>
,
-u
<username>
¶ Specifies a username to authenticate to the MongoDB instance, if your database requires authentication. Use in conjunction with the
--password
option to supply a password.
-
--password
<password>
,
-p
<password>
¶ Specifies a password to authenticate to the MongoDB instance. Use in conjunction with the
--username
option to supply a username.If you specify a
--username
and do not pass an argument to--password
,mongooplog
will prompt for a password interactively. If you do not specify a password on the command line,--password
must be the last option.
-
--authenticationDatabase
<dbname>
¶ New in version 2.4.
Specifies the database that holds the user’s (e.g
--username
) credentials.By default,
mongooplog
assumes that the database specified to the--db
argument holds the user’s credentials, unless you specify--authenticationDatabase
.See
userSource
, system.users Privilege Documents and User Privilege Roles in MongoDB for more information about delegated authentication in MongoDB.
-
--authenticationMechanism
<name>
¶ New in version 2.4.
Specifies the authentication mechanism. By default, the authentication mechanism is
MONGODB-CR
, which is the MongoDB challenge/response authentication mechanism. In MongoDB Enterprise,mongooplog
also includes support forGSSAPI
to handle Kerberos authentication.See Deploy MongoDB with Kerberos Authentication for more information about Kerberos authentication.
-
--dbpath
<path>
¶ Specifies a directory, containing MongoDB data files, to which
mongooplog
will apply operations from the oplog of the database specified with the--from
option. When used, the--dbpath
option enablesmongo
to attach directly to local data files and write data without a runningmongod
instance. To run with--dbpath
,mongooplog
needs to restrict access to the data directory: as a result, nomongod
can be access the same path while the process runs.
-
--directoryperdb
¶
Use the
--directoryperdb
in conjunction with the corresponding option tomongod
. This option allowsmongooplog
to write to data files organized with each database located in a distinct directory. This option is only relevant when specifying the--dbpath
option.
-
--journal
¶
Allows
mongooplog
operations to use the durability journal to ensure that the data files will remain valid during the writing process. This option is only relevant when specifying the--dbpath
option.
-
--db
<database>
,
-d
<database>
¶ The
--db
option and its alias-d
are inoperative.
-
--collection
<collection>
,
-c
<collection>
¶ The
--collection
option and its alias-c
are inoperative.
-
--seconds
<number>
,
-s
<number>
¶ Specify a number of seconds of operations for
mongooplog
to pull from theremote host
. Unless specified the default value is86400
seconds, or 24 hours.
-
--from
<host[:port]>
¶ Specify the host for
mongooplog
to retrieve oplog operations from.mongooplog
requires this option.Unless you specify the
--host
option,mongooplog
will apply the operations collected with this option to the oplog of themongod
instance running on the localhost interface connected to port27017
.
-
--oplogns
<namespace>
¶ Specify a namespace in the
--from
host where the oplog resides. The default value islocal.oplog.rs
, which is the where replica set members store their operation log. However, if you’ve copied oplog entries into another database or collection, use this option to copy oplog entries stored in another location.Namespaces take the form of
[database].[collection]
.
Usage¶
Consider the following prototype mongooplog
command:
Here, entries from the oplog of the mongod
running
on port 27017
. This only pull entries from the last 24 hours.
Use the --seconds
argument to capture
a greater or smaller amount of time. Consider the following example:
In this operation, mongooplog
captures 2 full days of
operations. To migrate 12 hours of oplog entries, use the
following form:
For the previous two examples, mongooplog
migrates entries
to the mongod
process running on the localhost interface
connected to the 27017
port. mongooplog
can also
operate directly on MongoDB’s data files if no mongod
is
running on the target host. Consider the following example:
Here, mongooplog
imports oplog operations from the
mongod
host connected to port 27017
. This migrates
operations to the MongoDB data files stored in the /srv/mongodb
directory. Additionally mongooplog
will use the durability
journal to ensure that the data files remain valid.