1

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?

0

1 Answer 1

1

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.

6
  • Thanks but I cannot find the right answer for my situation. Currently, I'm using oplog to sync data between sites on replicaSet, and I'm implementing to sharded cluster (3 shards). How to sync between sites with oplog on the sharded cluster?
    – tao hiko
    Jun 4, 2018 at 3:58
  • Is it possible to restore oplog to one shard and call a command to re-balance cluster after that to distribute data to other shards?
    – tao hiko
    Jun 4, 2018 at 4:03
  • @taohiko From your original description I assumed you were trying to backup and restore a sharded cluster. Can you elaborate on what you are trying to achieve? Are you migrating from a replica set to a sharded cluster or trying to sync data between multiple deployments? Are you able to stop writes to the original cluster as part of the migration process? The correct way to load data into an existing sharded cluster would be mongorestore via the mongos, but you would have to dump data without using the --oplog parameter.
    – Stennie
    Jun 4, 2018 at 11:48
  • I have initialled shard cluster by full restore backup from replicaSet but operation process, I need to apply any transactions from a primary to DR site. On replicaSet, I can use oplog for this but a sharded cluster, I don't have any ideas to do the same.
    – tao hiko
    Jun 4, 2018 at 12:00
  • @taohiko Sharded deployments more commonly have members of the same sharded cluster spread across multiple data centres for DR rather than having completely redundant clusters. For replication to an independent sharded cluster you'll need a different approach. For example, you could tail the oplog on each of the primaries and translate the changes into equivalent insert/update/remove operations applied through the mongos.
    – Stennie
    Jun 4, 2018 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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