applyOps's Oplog entries

231 views
Skip to first unread message

Philipp Knobel

unread,
Oct 29, 2013, 10:56:12 AM10/29/13
to mongod...@googlegroups.com
Hi all,

I recently got aware of the applyOps db command, which seems to be a good way to replicate the data over to a different node without dealing much myself with it (although this is quite easy). But it's behaviour is a bit strange to me.
If you call applyOps on the local database you don't get any Oplog Record created for command. I know that the local db doesn't get replicated and thus don't need to write to Oplog. But applyOps isn't bound to a specific database, thus the Oplog records used for local could modify replicated dbs. I can work around this by using a replicated DB for the applyOps command. But the Oplog record which is then created isn't what I would expect.

running this command:

 db.runCommand({"applyOps":[{ "ts" : Timestamp(1382985958, 1), "h" : NumberLong("-1797539322905744578"), "v" : 2, "op" : "i", "ns" : "test.collection", "o" : { "_id" : ObjectId("526eb0e682a153834ab771e8"), "b" : 1 } }]})


Will create this oplog record:

{ "ts" : Timestamp(1382987681, 1), "h" : NumberLong("2662222984365773812"), "v" : 2, "op" : "c", "ns" : "test.$cmd", "o" : { "applyOps" : [     {   "ts" : Timestamp(1382985958, 1),    "h" : NumberLong("-1797539322905744578"),   "v" : 2,    "op" : "i",     "ns" : "test.collection",   "o" : {     "_id" : ObjectId("526eb0e682a153834ab771e8"),   "b" : 1 } } ] } }

Where I was expecting some oplog record like this to appear:

{ "ts" : Timestamp(1382985958, 1), "h" : NumberLong("-1797539322905744578"), "v" : 2, "op" : "i", "ns" : "test.collection", "o" : { "_id" : ObjectId("526eb0e682a153834ab771e8"), "b" : 1 } }

With the applyOps Oplog Record created I kind of get the impression that I could have multiple on different documents modifications in one transaction, which isn't true. Is there anyway I can apply an Oplog record, without dealing myself with the different types of Oplog entries, which at the end generates the same structured Oplog entry on the target node like I have on the source node?

kind regards,

   Philipp

presid...@gmail.com

unread,
Oct 30, 2013, 5:25:27 AM10/30/13
to mongod...@googlegroups.com
You can use tool to sync data.

Philipp Knobel

unread,
Oct 30, 2013, 8:56:47 AM10/30/13
to mongod...@googlegroups.com
Do you refer to any special tool? But using some external tool is no option this replication needs to lay within our codebase.

president ccj

unread,
Oct 30, 2013, 9:04:58 AM10/30/13
to mongod...@googlegroups.com
then you must replay oplog yourself .  this code may be help  https://github.com/Tokutek/mongo/blob/master/src/mongo/tools/2toku.cpp
classs VanillaOplogPlayer




--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/dTf5VEJJWvY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Cyrus

Asya Kamsky

unread,
Oct 30, 2013, 10:12:02 AM10/30/13
to mongodb-user

There is mongooplog which ships with MongoDB.  The docs for it are here:  http://docs.mongodb.org/manual/reference/program/mongooplog/

Asya

--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages