I have a replicaset with 3 nodes(Primary-Secondary-Secondary) on version 4.2.21. The storage size is around 2TB. The data is expected to grow further in the coming months. To cater to that we are planning to move to a sharded setup.
I am considering using zstd compression but since the collection is already created I am unable to update the block compressor.
Any ideas around how can I update the compressor to zstd ?
One possible approach is to:
- Create a new collection with zstd commpression
- Copy the collection to the new collection (db.old_collection.aggregate([{ $match: {} }, { $out: “new_collection” }]))
- Delete the old collection. Rename the new collection
But this does not seem achievable for 2TBs of data. Is there any other way of achieving this ?
Can mongodump and restore help here ? I am doubtful if with dump and restore we can change the compressor because it also copies the collection metadata.