简体   繁体   English

重置MongoDB操作日志

[英]Reset the MongoDB oplog

I'm developing an application with a Elastich Search and MongoDB. 我正在使用Elastich Search和MongoDB开发应用程序。 The elastic search is using the MongoDB oplog to index the content via a component called a river. 弹性搜索使用MongoDB操作日志通过称为河流的组件对内容进行索引。

Is it possible to reset the MongoDB oplog so that all previous entries dissapear? 是否可以重置MongoDB操作日志,以便消失所有先前的条目?

The oplog is for replication and shouldn't be tampered with. 该oplog用于复制,不应被篡改。

The oplog is a capped collection: oplog是一个上限集合:

You cannot delete documents from a capped collection. 您无法从上限集合中删除文档。 To remove all records from a capped collection, use the 'emptycapped' command. 要从有上限的集合中删除所有记录,请使用“ emptycapped”命令。 To remove the collection entirely, use the drop() method. 要完全删除集合,请使用drop()方法。

http://docs.mongodb.org/manual/core/capped-collections/ http://docs.mongodb.org/manual/core/capped-collections/

You might want to use a tailable cursor and tail the oplog in your river. 您可能要使用可尾光标,并在您的河流中尾随 oplog。

If your app is going to read the oplog continuously, it would need the ability to start at a particular timestamp (ts) value. 如果您的应用要连续读取操作日志,则需要能够以特定的时间戳(ts)值启动。 Without that ability, if the app (or mongod) had to be restarted for any reason, it would have to re-process all the oplog entries that it had already processed but were still in the oplog. 如果没有该功能,则由于某种原因必须重新启动该应用程序(或mongod),它将不得不重新处理已经处理过但仍在oplog中的所有oplog条目。 If the app does have the ability to start at a ts value, then just query the oplog for the max value of ts, and use that as the starting point. 如果应用确实具有从ts值开始的功能,则只需在操作日志中查询ts的最大值,然后将其用作起点即可。

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

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