Mongodb master slave replication

mongodbreplication

I have set up master slave replication in mongo. It works fine for a few months, then suddenly replication fails. I have started it again with initial sync but during sync after a specific point it will again start resync and this process goes on and on, and slaves have not complete their initial sync.

The log file contains initial sync pending and again start resync again and again.

Best Answer

One reason could be that your oplog is too small.

On the master:

db.getReplicationInfo()

If timeDiffHours is shorter than the time that your initial sync takes, then the initial sync will fail and start again...

Resizing the oplog is quite easy, if this is indeed your problem. The documentation is here: http://docs.mongodb.org/manual/tutorial/change-oplog-size/