简体   繁体   English

MongoDB忽略配置文件中的dbPath

[英]MongoDB ignoring dbPath in config file

I'm setting up a fresh centOS 7 install following these instructions. 我将按照以下说明设置新的centOS 7安装。
https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-red-hat/ https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-red-hat/

Using systemctl start mongod I get a error saying /data/dbs does not exist (which it doesn't). 使用systemctl start mongod时出现错误,指出/ data / dbs不存在(实际上不存在)。 If I run 如果我跑步
sudo mongod -f /etc/mongod.conf Everything seems to work. sudo mongod -f /etc/mongod.conf一切似乎正常。 I don't really want to edit the init script if I can avoid it, but is there any way to fix this? 如果可以避免的话,我真的不想编辑初始化脚本,但是有什么办法可以解决此问题?

If you are installing using yum in CentOS7 by using the repository file described in Configure MongoDB v3.0 yum , the MongoDB instance stores its data files in /var/lib/mongo and its log files in /var/log/mongodb by default , and runs using the mongod user account. 如果要通过使用Configure MongoDB v3.0 yum中所述的存储库文件在CentOS7中使用yum进行安装,则默认情况下 ,MongoDB实例的数据文件存储在/var/lib/mongo ,其日志文件存储在/var/log/mongodb ,并使用mongod用户帐户运行。

the default config should contain a section similar to: 默认配置应包含类似于以下内容的部分:

storage:
    dbPath: /var/lib/mongo
    journal:
        enabled: true

Make sure whether there's no modification made to the content of your /etc/mongod.conf . 确保是否对/etc/mongod.conf的内容进行了/etc/mongod.conf

So the solution has ended up just being a new service which calls mongod with the parameters I want. 因此,解决方案最终只是一项新服务,该服务使用所需参数调用mongod。 I've disabled the default mongod service systemctl disable mongod Added my service file to /etc/systemd/system and enabled it systemctl enable my-mongod It works well enough and shouldn't be broken by updates as they come down. 我已经禁用了默认的mongod服务systemctl disable mongod我的服务文件添加到了/ etc / systemd / system并启用了它systemctl enable my-mongod它工作得很好,并且当它们下降时,不应被更新破坏。 The only thing that threw me for a bit is that the service had to be of type forking for it to work. 令我感到有些惊讶的是,该服务必须是分叉的类型,才能正常工作。

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

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