1

Mongodb supports statement-based-replication.

Would like to know, how the statement based replication converts the code internally on secondary node of mongodb.

Is that working related to the mysql Row-based-replication ?

3
  • Elaborate, please. SBR and RBR are two different ways to configure replication. Many systems (I don't know about MongoDB) work about the same in either mode. SBR replicates "INSERT ...", RBR replicates the row(s) that that INSERT added to the table. The effect should be identical.
    – Rick James
    Feb 21, 2015 at 19:51
  • The effect should be identical, but applying the transaction, the logs growth are some of the differences you face, when you tried SBR and RBR. For ex, RBR generate more logs, and SBR generate very less logs. SBR creates problem in deterministic functions like now(). LIkewise, would like to know how the statement based replication internally occurs in mongodb, and whats the pros and cons of the same?
    – s_ramesh
    Feb 26, 2015 at 10:08
  • NOW() (and similar functions) are not a problem because the Master includes the value of NOW() in the binlog. Then the Slave uses that value instead of computing NOW(). Relative size of SBR vs RBR can be minor or significant -- consider a DELETE or UPDATE that affects a million rows. RBR's binlog is much fatter in that case.
    – Rick James
    Feb 26, 2015 at 16:56

1 Answer 1

2

Mongodb do support only row based replication for the data durability among the master and slaves, when you hit a update command like below

db.collname.update({"empid":43123},{$set:{"age":{$inc:1}}})

the above statement search for the employee with employee id empid 43123 and increaments his age to 1, if his age is 26 it will make it as 27, this operation happens only in master, if you go and check the oplog for this statement the oplog entry will be like below

db.collname.update({"empid":43123},{$set:{"age":27}})

so mongodb replication always work on the basis of row which is updated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.