Ramesh Murugesan
Ramesh Murugesan

Reputation: 5013

How to create mongodb oplog for database?

Recently I purchased cluster account from MongoDB atlas. I had checked UI and MongoDB documentation but don't know create oplog db. And how to create a connection string for oplog?

Upvotes: 0

Views: 2308

Answers (2)

samo
samo

Reputation: 174

Oplog collection is automatically created and maintained by mongoDB and is created under the local database. It is used internally by mongoDB to maintain the various nodes in sync in a replica set. Assume you have a three node replica set, one primary and two secondary. When a write operation happens in the primary, the event is logged in oplog collection and is used internally to replicate the same change in the secondary nodes.

So to use oplog you will need a MongoDB server configured as a replica set. Standalone instances of mongoDB do not have oplog as there is no need for replication in this case.

However, you may start a standalone instance as a replica set by using the command,

  1. Start Mongo server in replica mode.
    • mongod --dbPath <path_to_data_file> --replSet rs0
  2. Initiate the replica set.(Execute from mongo shell)
    • rs.initiate();

Upvotes: 4

Probal
Probal

Reputation: 100

oplog is a mongodb replication feature. If you have choose replication cluster, you have it in the database named "local". See the collections in "local" database.

Upvotes: 2

Related Questions