Mongodb – Process to reclaim free space from mongodb ,replication is there

disk-spacemongo-repairmongodbreplication

We are facing space pressure on production server so we are planning to reclaim space from prod instance.replication is there ,can anyone help me to know complete process in sequence to reclaim free space.

I am thinking to use repair db commend at slave node to reclaim space but don't know how to make secondary node after repairing to primary server and start replication again.

Best Answer

Once and for all: The database repair command is potentially harmful and is advised against

You should not use repairDatabase for data recovery unless you have no other option.

And

This command obtains a global write lock and will block other operations until it has completed.

Hardly what you want in a production system. I already answered a similar, though not identical question. However, the same rules apply. Read the part on capacity planning closely.

And honestly: if you have to ask for the procedure, you really, really, really should not even think about executing it. Even when you get a detailed How-To, you will lack any knowledge of potential side effects. If it is a production system, get yourself a DBA. It is worth it.