I have 2 computers in different places (so it's impossible to use the same wifi network). One contains about 50GBs of data (MongoDB files) that I want to move to the second one which has much more computation power for analysis. But how can I make MongoDB on the second machine recognize that folder?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
When you start mongod
process you provide an argument to it --dbpath /directory
which is how it knows where the data folder is.
All you need to do is:
- stop the
mongod
process on the old computer. wait till it exits. - copy the entire /data/db directory to the new computer
- start
mongod
process on the new computer giving it--dbpath /newdirectory
argument.
The mongod
on the new machine will use the folder you indicate with --dbpath. There is no need to "recognize" as there is nothing machine specific in that folder, it's just data.
回答2:
quite easy for windows, just move the data folder to the target location run cmd "C:\your\mongodb\bin-path\mongod.exe" --dbpath="c:\what\ever\path\data\db"
回答3:
Maybe what you didn't do was export or dump the database. Databases aren't portable therefore must be exported or created as a dumpfile.
Here is another question where the answer is further explained