简体   繁体   中英

MongoDB enable oplog windows

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

  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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM