简体   繁体   中英

Reset the MongoDB oplog

I'm developing an application with a Elastich Search and MongoDB. The elastic search is using the MongoDB oplog to index the content via a component called a river.

Is it possible to reset the MongoDB oplog so that all previous entries dissapear?

The oplog is for replication and shouldn't be tampered with.

The oplog is a capped collection:

You cannot delete documents from a capped collection. To remove all records from a capped collection, use the 'emptycapped' command. To remove the collection entirely, use the drop() method.

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

You might want to use a tailable cursor and tail the oplog in your river.

If your app is going to read the oplog continuously, it would need the ability to start at a particular timestamp (ts) value. 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. 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.

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