- Reference >
- MongoDB Package Components >
mongooplog
mongooplog¶
Deprecated since version 3.2.
macOS Sierra and Go 1.6 Incompatibility
Users running on macOS Sierra require the 3.2.10 or newer version of mongooplog.
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.
Run mongooplog from the system command line, not the mongo shell.
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¶
Changed in version 3.0.0: mongooplog removed the --dbpath as well as related
--directoryperdb and --journal options. To use
mongooplog, you must run mongooplog against a running
mongod or mongos instance as appropriate.
-
mongooplog¶
-
--help¶ Returns information on the options and use of mongooplog.
-
--verbose,-v¶ Increases the amount of internal reporting returned on standard output or in log files. Increase the verbosity with the
-vform by including the option multiple times, (e.g.-vvvvv.)
-
--quiet¶ Runs mongooplog in a quiet mode that attempts to limit the amount of output.
This option suppresses:
- connection accepted events
- connection closed events
-
--version¶ Returns the mongooplog release number.
-
--uri<connectionString>¶ New in version 3.4.6.
Specify a resolvable URI connection string to connect to the MongoDB deployment.
For more information on the components of the connection string, see the Connection String URI Format documentation.
Important
The following command-line options cannot be used in conjunction with
--urioption:--host--port--username--password(if the URI connection string also includes the password)--authenticationDatabase--authenticationMechanism
Instead, specify these options as part of your
--uriconnection string.
-
--host<hostname><:port>,-h<hostname><:port>¶ Specifies a resolvable hostname for the
mongodinstance to whichmongooplogwill apply oplog operations retrieved from the server specified by the--fromoption.By default mongooplog attempts to connect to a MongoDB instance running on the localhost on port number
27017.To connect to a replica set, specify the
replica set nameand a seed list of set members. Use the following form:You can always connect directly to a single MongoDB instance by specifying the host and port number directly.
-
--port¶ Specifies the port number of the
mongodinstance wheremongooplogwill apply oplog entries. Specify this option only if the MongoDB instance to connect to is not running on the standard port of27017. You may also specify a port number using the--hostcommand.
-
--ipv6¶ Removed in version 3.0.
Enables IPv6 support and allows mongooplog to connect to the MongoDB instance using an IPv6 network. Prior to MongoDB 3.0, you had to specify
--ipv6to use IPv6. In MongoDB 3.0 and later, IPv6 is always enabled.
-
--ssl¶ New in version 2.6.
Enables connection to a
mongodormongosthat has TLS/SSL support enabled.For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .
-
--sslCAFile<filename>¶ New in version 2.6.
Specifies the
.pemfile that contains the root certificate chain from the Certificate Authority. Specify the file name of the.pemfile using relative or absolute paths.Starting in version 3.4, if
--sslCAFileorssl.CAFileis not specified and you are not using x.509 authentication, the system-wide CA certificate store will be used when connecting to an TLS/SSL-enabled server.If using x.509 authentication,
--sslCAFileorssl.CAFilemust be specified.Warning
Version 3.2 and earlier: For TLS/SSL connections (
--ssl) tomongodandmongos, if the mongooplog runs without the--sslCAFile, mongooplog will not attempt to validate the server certificates. This creates a vulnerability to expiredmongodandmongoscertificates as well as to foreign processes posing as validmongodormongosinstances. Ensure that you always specify the CA file to validate the server certificates in cases where intrusion is a possibility.For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .
-
--sslPEMKeyFile<filename>¶ New in version 2.6.
Specifies the
.pemfile that contains both the TLS/SSL certificate and key. Specify the file name of the.pemfile using relative or absolute paths.This option is required when using the
--ssloption to connect to amongodormongosthat hasCAFileenabled withoutallowConnectionsWithoutCertificates.For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .
-
--sslPEMKeyPassword<value>¶ New in version 2.6.
Specifies the password to de-crypt the certificate-key file (i.e.
--sslPEMKeyFile). Use the--sslPEMKeyPasswordoption only if the certificate-key file is encrypted. In all cases, the mongooplog will redact the password from all logging and reporting output.If the private key in the PEM file is encrypted and you do not specify the
--sslPEMKeyPasswordoption, the mongooplog will prompt for a passphrase. See TLS/SSL Certificate Passphrase.For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .
-
--sslCRLFile<filename>¶ New in version 2.6.
Specifies the
.pemfile that contains the Certificate Revocation List. Specify the file name of the.pemfile using relative or absolute paths.For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .
-
--sslAllowInvalidCertificates¶ New in version 2.6.
Bypasses the validation checks for server certificates and allows the use of invalid certificates. When using the
allowInvalidCertificatessetting, MongoDB logs as a warning the use of the invalid certificate.Starting in MongoDB 3.4.16, if you specify
--sslAllowInvalidCertificatesorssl.allowInvalidCertificates: truewhen using x.509 authentication, an invalid certificate is only sufficient to establish a TLS/SSL connection but is insufficient for authentication.Warning
For TLS/SSL connections to
mongodandmongos, avoid using--sslAllowInvalidCertificatesif possible and only use--sslAllowInvalidCertificateson systems where intrusion is not possible.If the
mongoshell (and other MongoDB Tools) runs with the--sslAllowInvalidCertificatesoption, themongoshell (and other MongoDB Tools) will not attempt to validate the server certificates. This creates a vulnerability to expiredmongodandmongoscertificates as well as to foreign processes posing as validmongodormongosinstances.For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .
-
--sslAllowInvalidHostnames¶ New in version 3.0.
Disables the validation of the hostnames in TLS/SSL certificates. Allows mongooplog to connect to MongoDB instances even if the hostname in their certificates do not match the specified hostname.
For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .
-
--sslFIPSMode¶ New in version 2.6.
Directs the mongooplog to use the FIPS mode of the installed OpenSSL library. Your system must have a FIPS compliant OpenSSL library to use the
--sslFIPSModeoption.Note
FIPS-compatible TLS/SSL is available only in MongoDB Enterprise. See Configure MongoDB for FIPS for more information.
-
--username<username>,-u<username>¶ Specifies a username with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the
--passwordand--authenticationDatabaseoptions.Note
You cannot specify both
--usernameand--uri.
-
--password<password>,-p<password>¶ Specifies a password with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the
--usernameand--authenticationDatabaseoptions.Changed in version 3.0.2: To prompt the user for the password, pass the
--usernameoption without--passwordor specify an empty string as the--passwordvalue, as in--password "".Note
You cannot specify both
--passwordand--uri.
-
--authenticationDatabase<dbname>¶ Specifies the authentication database where the specified
--usernamehas been created. See Authentication Database.Note
You cannot specify both
--authenticationDatabaseand--uri.
-
--authenticationMechanism<name>¶ Default: SCRAM-SHA-1
Changed in version 2.6: Added support for the
PLAINandMONGODB-X509authentication mechanisms.Changed in version 3.0: Added support for the
SCRAM-SHA-1authentication mechanism. Changed default mechanism toSCRAM-SHA-1.Specifies the authentication mechanism the mongooplog instance uses to authenticate to the
mongodormongos.Value Description SCRAM-SHA-1 RFC 5802 standard Salted Challenge Response Authentication Mechanism using the SHA1 hash function. MONGODB-CR MongoDB challenge/response authentication. MONGODB-X509 MongoDB TLS/SSL certificate authentication. GSSAPI (Kerberos) External authentication using Kerberos. This mechanism is available only in MongoDB Enterprise. PLAIN (LDAP SASL) External authentication using LDAP. You can also use PLAINfor authenticating in-database users.PLAINtransmits passwords in plain text. This mechanism is available only in MongoDB Enterprise.Note
You cannot specify both
--authenticationMechanismand--uri.
-
--gssapiServiceName¶ New in version 2.6.
Specify the name of the service using GSSAPI/Kerberos. Only required if the service does not use the default name of
mongodb.This option is available only in MongoDB Enterprise.
-
--gssapiHostName¶ New in version 2.6.
Specify the hostname of a service using GSSAPI/Kerberos. Only required if the hostname of a machine does not match the hostname resolved by DNS.
This option is available only in MongoDB Enterprise.
-
--seconds<number>,-s<number>¶ Specify a number of seconds of operations for
mongooplogto pull from theremote host. Unless specified the default value is86400seconds, or 24 hours.
-
--from<host[:port]>¶ Specify the host for
mongooplogto retrieve oplog operations from.mongooplogrequires this option.Unless you specify the
--hostoption,mongooplogwill apply the operations collected with this option to the oplog of themongodinstance running on the localhost interface connected to port27017.
-
--oplogns<namespace>¶ Specify a namespace in the
--fromhost 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 or are pulling oplog entries from a master-slave deployment, use--oplognsto apply oplog entries stored in another location. Namespaces take the form of[database].[collection].
Use¶
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: