Why after deleting a 110+ GB collection, my /var/lib/mongodb directory still have same size?

Solution 1:

As with most database systems, the database files does not shrink when you delete data, the data is just removed/marked as deleted, and the space is reused.

You'll need to run db.repairDatabase() to compact space as noted here

Solution 2:

While the above mongodump/drop/mongorestore approach will work fine from a technical perspective, it will require you to take the database offline while you do so, which would be a service-affecting event.

If you would like do this without downtime AND if you are using MongoDB Replica Sets[1], you could do so like this:

  1. Select a member and stop the MongoDB there (service mongodb stop). If this was the PRIMARY, wait for another member to be elected the PRIMARY.
  2. Remove the data files on this member (cd /var/lib/mongodb; rm *).
  3. Restart MongoDB service again (service mongodb start).
  4. Wait for the member to resync to the PRIMARY (rs.status()).
  5. This will rebuild only the required (smaller) data files.

Then repeat the above steps for each of the other members in the Replica Set.

[1] https://docs.mongodb.org/manual/tutorial/deploy-replica-set)