mongodbHow to set MongoDB oplog?
MongoDB oplog is a special capped collection that keeps a rolling record of all operations that modify the data stored in your databases. To set up oplog, you need to start MongoDB with the --replSet
option.
mongod --replSet myReplSet
Once the MongoDB instance is running, you can initiate the replica set using the rs.initiate()
command.
rs.initiate()
Code explanation
-
mongod --replSet
: This command starts MongoDB with the--replSet
option, which enables replication and sets up the oplog. -
rs.initiate()
: This command initiates the replica set and creates the oplog.
Helpful links
More of Mongodb
- How to use watch in MongoDB?
- How to create a many to many relation in MongoDB?
- How to rename a field in MongoDB?
- How to update many documents in MongoDB?
- How to join two collections in MongoDB?
- How to use MongoDB queue?
- What is MongoDB default port?
- How to query with "not equal" condition in MongoDB?
- How to use eq in MongoDB?
- How to work with JSON data in MongoDB?
See more codes...