0

Try to enable oplog locally

Add to C:\Program Files\MongoDB\Server\4.2\bin\mongod.cfg

replication:
  replSetName: rs0
  oplogSizeMB: 100

Restart mongod, but local.oplog does not exist

How correctly enable oplog?

UPD: Use MongoDB 4.2, Windows 10

leonheess
  • 16,068
  • 14
  • 77
  • 112
VoidName
  • 340
  • 2
  • 16
  • please also mention MongoDB version, Operating system as well – Manjeet Thakur Jan 10 '20 at 11:42
  • @ManjeetThakur added to the question – VoidName Jan 10 '20 at 12:25
  • 1
    If you are trying to [Convert a Standalone to a Replica Set](https://docs.mongodb.com/manual/tutorial/convert-standalone-to-replica-set/) you need to run [`rs.initiate()`](https://docs.mongodb.com/manual/reference/method/rs.initiate/) to create a replica set configuration and initial oplog. If you've already done this, please edit your question to confirm how you are checking for the existence of the oplog. You can use `rs.printReplicationInfo()` in the `mongo` shell to confirm the configured oplog size as well as first and last events. – Stennie Jan 11 '20 at 12:57
  • @Stennie , run mongod with `--replSet rs0` then run `rs.initiate()`, oplog start work, thanks – VoidName Jan 14 '20 at 19:24

1 Answers1

0
  1. Add the replication configs in the mongod.cfg file.

  2. Restart MongoDB from services.

  3. Open MongoDB from a command prompt.

  4. Execute the following command in the mongo terminal:

    rs.initiate({_id:"rs0", members: [{"_id":1, "host":"127.0.0.1:27017"}]})
    

    After that you'll see something like this:

    {
        "info" : "Config now saved locally.  Should come online in about a minute.",
        "ok" : 1
    }
    
  5. Switch to the local database using use local.

  6. You can verify oplog.rs by viewing the collections using: show collections

You'll see that oplog.rs will be listed along with other collections.

oplog.rs
replset.election
replset.minvalid
replset.oplogTruncateAfterPoint
startup_log
system.replset
system.rollback.id
double-beep
  • 5,031
  • 17
  • 33
  • 41
Manoj N
  • 1
  • 1