0

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.

sudhir
  • 1
  • 1

2 Answers2

1

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.

Markus W Mahlberg
  • 3,301
  • 1
  • 15
  • 19
-1

you can use repair db command for availing space. As you have mentioned that you are using replica set so you can repeat below steps (I am assuming that you are using 3 member replica set):

  1. Stop one of your secondary and start it on some other port and do db repair.
  2. Now restart your secondary with old port with replset option.

Repeat it for remaining secondary.

For primary ,you can step it down to secondary using "rs.stepDown" and then perform above mentioned steps. But before you start doing this make sure you have available space in your Db it should be equal to same as db size + 2GB.

Gagan Sidhu
  • 120
  • 7