What do i do to add a second with a backup (mongodump --oplog )?

I have a replset, but its oplog is too big , even more biger than the db’s storage size, I want to dump the db , then restore to a instance, add the restored instance to the replset at last, I don’t know the detail of operating ,so could somebody tell me the detail and show me the refer and code ? thanks very much .

Hi @feng_deng and welcome back to MongoDB community forum!!

The issue of growing oplog size could be possibly resolved by upgrading to version 4.4 or more, where

MongoDB 4.4 supports specifying a minimum oplog retention period in hours, where MongoDB only removes an oplog entry if:

  • The oplog has reached the maximum configured size, and
  • The oplog entry is older than the configured number of hours.

Please refer to the Replica Set Oplog for more details.

Now, for

Regarding the dumping and restoration, you can visit the documentation for MongoDB tools for Backup and restore.

Let us know if you have more queries.

Regards
Aasawari

1 Like

mongodb version 4.4.18
replSetResizeOplog , I reconfig oplog size sucessfully , but when i do the action of compact at the second optlog resized (mongo shell connect to sencond directly, not a replset connect character), it prompt auth failed, even i give the user and password correct,so it doesn’t do the compact . so what should i do to resolve the problem
i’m sure the user is cluster admin and have the privilege of root .
refer https://www.mongodb.com/docs/manual/tutorial/change-oplog-size/

Hi @feng_deng

If the secondary required authentication, you need to provide the right privileges on the local database to perform the operation. You can follow the documentation for the same.

Regards
Aasawari