简体   繁体   English

MongoDB 启用 oplog 窗口

[英]MongoDB enable oplog windows

Try to enable oplog locally尝试在本地启用oplog

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

replication:
  replSetName: rs0
  oplogSizeMB: 100

Restart mongod, but local.oplog does not exist重启mongod,但是local.oplog不存在

How correctly enable oplog?如何正确启用oplog?

UPD: Use MongoDB 4.2, Windows 10 UPD:使用 MongoDB 4.2,Windows 10

  1. Add the replication configs in the mongod.cfg file.mongod.cfg文件中添加复制配置。

  2. Restart MongoDB from services.从服务重启 MongoDB。

  3. Open MongoDB from a command prompt.从命令提示符打开 MongoDB。

  4. Execute the following command in the mongo terminal:在 mongo 终端中执行以下命令:

     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 .使用use local切换到本地数据库。

  6. You can verify oplog.rs by viewing the collections using: show collections您可以使用以下oplog.rs查看集合来验证oplog.rs show collections

You'll see that oplog.rs will be listed along with other collections.您将看到oplog.rs将与其他集合一起列出。

oplog.rs
replset.election
replset.minvalid
replset.oplogTruncateAfterPoint
startup_log
system.replset
system.rollback.id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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