Mongo Update compressor for an existing collection

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:

  1. Create a new collection with zstd commpression
  2. Copy the collection to the new collection (db.old_collection.aggregate([{ $match: {} }, { $out: “new_collection” }]))
  3. 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.

Hi @Ishrat_Jahan ,

Usually we recommend to setup on the instance level and initial sync each replica set member one by one with zstd setup on.

Thanks
Pavel

@Pavel_Duchovny Instead of doing step by step initial sync on each of the instances, can we setup a new replicaset and use mongomirror to migrate the data?

@Ishrat_Jahan Potentially you can if the target is an Atlas cluster deployment.

But it requires your application to change your connection string and restart it most probably, so doing this via a resync is the recommended way in this scenario.

Would the mongo mirror work if the both the source and target are not Atlas cluster deployment ?

It might work BUT it’s not supported and was not design for non atlas migrations…

So it’s at your own risk…