Master-Slave operation Log Oplog
MongoDB's replica set schema is a log to store writes, and this log is called "Oplog". Oplog.rs is a fixed-length capped collection that exists in the "local" database for recording replica sets operations logs. By default, the 64-bit mongodb,oplog is relatively large and can reach 5% of the disk space. The size of the Oplog can be set by the Mongod parameter "--oplogsize".
rs1:primary> use localswitched to db localrs1:primary> show collectionsoplog.rssystem.replsetrs1: PRIMARY>"ts": {"T": 1338457763000, "I": 1}, "H": Numberlong (0), "OP": "N", "ns": "", "O": {"msg " :" initiating set "" ts ": {" T ": 1338459114000," I ": 1}," H ": Numberlong (" 5493127699725549585 ")," Op ":" I "," ns ":" Test.c1 "," O ": {" _id ": ObjectId (" 4fc743e9aea289af709ac6b5 ")," Age ":" Name ":" Ton Y " }}rs1:primary>
View Code
Field description
TS: Timestamp for an operation
OP: Operation type, as follows:
I:insert
D:delete
U:update
NS: The namespace, which is the collection name of the operation
O:document's Content
To view the Oplog metadata information for master:
Rs1:primary>. 6837158203125MBlog length start to End:1351secs (017:49:23 gmt+ 080018:11:54 gmt+080018:21:58 gmt+0800 (CST) rs1:primary>
View Code
Configured Oplog Size: configured oplog file size
Log length start to End:oplog time period of the log
Oplog first Event Time: The generation of a transaction log
Oplog Last Event time: The final transaction log is generated
Now: the time
To view the synchronization status of a Slave
Rs1:primary> db.printslavereplicationinfo () source:localhost:2801118:11:54 gmt+0800 (CST)= 884secs ago (0. 25hrs) Source:localhost:2801218:11:54 gmt+0800 (CST) = 884secs ago (0. 25hrs) rs1:primary>
View Code
Field description
Source: IP and port from the library
Syncedto: Current synchronization situation, how long delays and other information
Master-Slave configuration information
In the local library, there is not only a collection of master-slave log oplog, but also a collection for recording master-slave configuration information, namely: System.replset
rs1:primary> use localswitched to db localrs1:primary> show collectionsoplog.rssystem.replsetrs1: PRIMARY>"_id": "Rs1", "Version": 1, "members" : [{"_id": 0,"host": "localhost:28010 "},{" _id ": 1," host ":" localhost:28011 "},{" _id ": 2," host ":" localhost:28012 " }]}rs1:primary>
View Code
As you can see from this collection, the configuration information for Replica sets can also be performed on any of the member instances rs.conf () to view the configuration information.
MongoDB Finishing Note のreplica Oplog