0

I have a local mongodb database that i want to transfer to a free tier aws ec2 t3.micro instance.

The problem is that one collection in the db is a bit larger(1.2 GB, 24M docs), so there is no way i can index it locally on the dinky little aws machine. I have the storage space but don't have the compute (ram and cpu) to create a index.

I tried transfering db with indexes via mongodump and mongorestore, but it doesn't look like it actually transfers precomputed indexes.

mongorestore hangs the entire ssh session when restoring the particular large index (waited for hours)

2024-06-10T23:27:39.102+0300    index: &idx.IndexDocument{Options:primitive.M{"name":"symbol_1_date_1", "v":2}, Key:primitive.D{primitive.E{Key:"symbol", Value:1}, primitive.E{Key:"date", Value:1}}, PartialFilterExpression:primitive.D(nil)} <-- hangs on this
5
  • I don't understand what you are trying to achieve. If storage is a concern for index, even if you precompute the index, it will not have enough storage to accomodate the transferred index. Most canonical way would be rebuilding the index on the new machine.
    – ray
    Commented Jun 11 at 2:11
  • I have the storage space, that is not the problem. The problem is that I don't have the compute (cpu and ram) to rebuild the index via mongorestore. Im asking if it's possible to yank and drop the index from my local machine to aws with minimal compute. Or am I fundamentally misundestanding how indexing works?
    – dumb_dumb_man
    Commented Jun 11 at 2:31
  • 1
    "but don't have the compute (ram and cpu) to create a index." How do you know you don't have the RAM/CPU to create the index? They are created in the background so may take some time if you have low RAM/CPU. Anyway, you could Back Up and Restore Using LVM on Linux. Other options also on that page.
    – aneroid
    Commented Jun 11 at 6:07
  • Try mongoexport and mongoimport and then create the indexes manually. Commented Jun 11 at 6:26
  • What is your partialFilterExpression? Error message "D(nil)" looks a bit strange. Commented Jun 11 at 6:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.