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?
CodePudding user response:
If you want to have databases in different disks under the same dbPath , this is the option:
Add the option --directoryperdb in the mongod config file or at startup.
db.createDatabase("newDatabase")
You will see inside the dbPath folder for the new database like: \dbPath\newDatabase
Stop the mongodb process.
Copy the content from \dbPath\neWDatabase to your SSD let say: ssd:\newData
make link to the folder with:
mklink /d \newData \dbPath\newDatabase
or follow this tutotial
- 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 ...
CodePudding user response:
If you're on windows, create the configuration file mongod.cfg
. And add the entry as
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
net:
bindIp: 0.0.0.0
port: 27017
Learn more at - https://www.ge.com/digital/documentation/meridium/Help/V43020/Default/Subsystems/ModuleDeployment/Content/ConfigureAWindowsServiceForMongoDB.htm