I have a mongodb replica set configuration of one primary machine, one secondary machine and one arbiter machine. The primary and secondary machines have 2 collections (each in its own database)
I need to delete a few Gb from one collection and leave the other collection intact. I am brand new at this so I would like to get ideas/gotchas on this. I am thinking of following this procedure:
- Remove the secondary from the replica set.
- In the secondary, for the collection that I want to delete, do a mongodump of the data I want to keep.
- Do a mongo restore from that dump.
- Re-add the secondary back to the replica set. I think I will have to set priorities so that the primary does not become secondary?
The secondary will sync/catch up with the primary I hope but what happens to the data that I deleted in the secondary? Does the primary removes it from itself? (which is what I want)
Do I need to do anything with the Primary?
Rolling Maintenance:
Cleanup during the Rolling Maintenance
Here I am not very sure and can only make some guesses for now because I didn't test this yet. What you can do during a Rolling maintenance is:
Now about deleting data? That you need to test on a local small replica.
https://dba.stackexchange.com/questions/28269/disk-space-recovery-on-mongodb-replicaset-secondaries
And have a look at https://university.mongodb.com => M202: MongoDB Advanced Deployment and Operations ... This issue is handled in those free lessons.