1

I am running Mongo on Windows 10. Data access is made trugh Pymongo (Python). All my data is stored in an old large HDD, but I would like to have some smaller collection stored on a much faster SSD? When I create a new collection either trough Compass or Pymongo there is no option to specify the path on disk.

Is it possible to learn such power?

  • Just a hint, once you enabled `storage.directoryPerDB` you may also enable [`storage.wiredTiger.engineConfig.directoryForIndexes`](https://docs.mongodb.com/manual/reference/configuration-options/#mongodb-setting-storage.wiredTiger.engineConfig.directoryForIndexes) to move also the indexes to faster SSD. – Wernfried Domscheit Mar 13 '22 at 15:28

1 Answers1

2

If you want to have databases in different disks under the same dbPath , this is the option:

  1. Add the option --directoryperdb in the mongod config file or at startup.

  2. db.createDatabase("newDatabase")

  3. You will see inside the dbPath folder for the new database like: \dbPath\newDatabase

  4. Stop the mongodb process.

  5. Copy the content from \dbPath\neWDatabase to your SSD let say: ssd:\newData

  6. make link to the folder with:

    mklink /d \newData \dbPath\newDatabase
    

or follow this tutotial

  1. Start the mongodb process again.

Note: As suggested by @Wermfried in the comment it is safe to have the option --directoryperdb set initially in the member before to get populated ...

R2D2
  • 9,410
  • 2
  • 12
  • 28
  • I think you **cannot** just enable `storage.directoryPerDB` on an existing deployment and simply restart the database. All your data might get lost! The documentation clearly states "create a backup with `mongodump` .... restore with `mongorestore`" I don't think "*Copy the content from \dbPath\neWDatabase to your SSD let say: ssd:\newData*" will work – Wernfried Domscheit Mar 13 '22 at 15:29
  • Previously in mmapv1 it was even posible to copy online , in WT it is abit tricky since WT write checksum in root dbPath. But you are right for the backup/restore even better to replicate to other member with directoryPerDB already set and later just remove the old member ... – R2D2 Mar 13 '22 at 15:39
  • 1
    Thanks a lot! I was able to move the collection to a brand new DB on another path – Andrea Barral Mar 15 '22 at 13:15