Mongodb – Can mongorestore replay oplog via mongos

mongodbsharding

I'm using MongoDB 3.6.2 and configured to sharded cluster.
I used mongodump to dump oplog from every shard and then restored by mongorestore via mongos, but I got below error.

Failed: no oplog file to replay; make sure you run mongodump with –oplog

And then I restored by mongod that works.

Is it possible to restore oplog via mongos? If yes, how to do?

Best Answer

You cannot replay oplogs through a mongos process: oplog entries can only be applied via a mongod that is the primary of a replica set.

Please see the MongoDB documentation for tutorials on Supported Backup Methods including Backing up a Sharded Cluster with Database Dumps.