Oplog stands for Operation Log.
It is not a log file but a capped collection (collection with fixed size) stored in MongoDb.
Precisely it is stored in local database on MongoDb server.
What is the use?
It is introduced to support replication (duplication of data) in MongoDb.
It mainly monitors CRUD operations in MongoDb and writes to local db in oplog.rs collection
I am using mongoDB Version 3.2
There are 2 ways to access oplog in mongoDB -
1.With replica Set (using cluster of hosts)
2.Without replica Set (using each mongoDB instance as Master)
1st way =>
Prerequisite -> connect to replica set
mongod --replSet rs0
How to query it in mongo shell ?
1. Use local database.
use local;
2. documents in oplog.rs will give you latest oplog data.
db.oplog.rs.find();
2nd Way =>
Prerequisite -> connect as Master user
(Though each connected node in version 3.2 is master by default but oplog does not generate.Hence this step is mandatory.)
mongod --master
1. Use local database
use local;
2.docs in oplog.$main will give you latest oplog data.
db.oplog.$main.find();
You will get list of all latest oplog records here.
It is not a log file but a capped collection (collection with fixed size) stored in MongoDb.
Precisely it is stored in local database on MongoDb server.
What is the use?
It is introduced to support replication (duplication of data) in MongoDb.
It mainly monitors CRUD operations in MongoDb and writes to local db in oplog.rs collection
I am using mongoDB Version 3.2
There are 2 ways to access oplog in mongoDB -
1.With replica Set (using cluster of hosts)
2.Without replica Set (using each mongoDB instance as Master)
1st way =>
Prerequisite -> connect to replica set
mongod --replSet rs0
How to query it in mongo shell ?
1. Use local database.
use local;
2. documents in oplog.rs will give you latest oplog data.
db.oplog.rs.find();
2nd Way =>
Prerequisite -> connect as Master user
(Though each connected node in version 3.2 is master by default but oplog does not generate.Hence this step is mandatory.)
mongod --master
1. Use local database
use local;
2.docs in oplog.$main will give you latest oplog data.
db.oplog.$main.find();
You will get list of all latest oplog records here.
No comments:
Post a Comment