简体   繁体   English

更改Mongodb的dbPath

[英]Change the dbPath for Mongodb

I'm having trouble changing the dbPath of MongoDB on my development machine. 我在开发机器上更改MongoDB的dbPath时遇到问题。

I used the install instructions found on the MongoDB site. 我使用了MongoDB站点上的安装说明 I have installed MongoDB 3.4.0-rc2 on to Linux Mint 18, my development machine. 我已将MongoDB 3.4.0-rc2安装到我的开发机器Linux Mint 18上。

My / partition is relatively small and I would like MongoDB to store the DB files in my much larger /home partition. /分区相对较小,我希望MongoDB将DB文件存储在我更大的/home分区中。 In /etc/mongod.conf I have changed dbPath to dbPath: /home/mongodb/data /etc/mongod.conf我已将dbPath更改为dbPath: /home/mongodb/data

The permissions are fine and if I start mongod using mongod -f /etc/mongod.conf everything works as expected. 权限很好,如果我使用mongod -f /etc/mongod.conf启动mongod,一切都按预期工作。

If I don't specify the config file I get the following error 如果我没有指定配置文件,我会收到以下错误

exception in initAndListen: 29 Data directory /data/db not found., terminating

When trying to start the service nothing seems to happen, and from what I can tell, no logs are created. 当尝试启动服务时似乎没有任何事情发生,从我所知道的,没有创建日志。

While reading through the MongoDB documentation I found the following 在阅读MongoDB文档时,我发现了以下内容

The Linux package init scripts do not expect storage.dbPath to change from the defaults. Linux软件包init脚本不希望storage.dbPath从默认值更改。 If you use the Linux packages and change storage.dbPath, you will have to use your own init scripts and disable the built-in scripts. 如果使用Linux软件包并更改storage.dbPath,则必须使用自己的init脚本并禁用内置脚本。

How do I disable the built in scripts, where are they? 如何禁用内置脚本,它们在哪里? Or am I doing all this wrong? 或者我做错了什么?

The error 错误

exception in initAndListen: 29 Data directory /data/db not found., terminating

just because the default storage.dbPath is /data/db on Linux and OS X, you can find it on https://docs.mongodb.com/v3.2/reference/configuration-options/#storage.dbPath . 只是因为Linux和OS X上的默认storage.dbPath/data/db ,您可以在https://docs.mongodb.com/v3.2/reference/configuration-options/#storage.dbPath上找到它。

The built in scripts on /etc/init.d/mongod , if you want to disable it, just remove it. /etc/init.d/mongod上的内置脚本,如果要禁用它,只需将其删除即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM