Moving MongoDB's data folder?

后端 未结 4 1440
我在风中等你
我在风中等你 2021-02-12 18:08

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 on

4条回答
  •  走了就别回头了
    2021-02-12 18:58

    When you start mongodprocess you provide an argument to it --dbpath /directory which is how it knows where the data folder is.

    All you need to do is:

    1. stop the mongod process on the old computer. wait till it exits.
    2. copy the entire /data/db directory to the new computer
    3. 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.

提交回复
热议问题