[英]MongoDB not using /etc/mongodb.conf after I changed dbpath
Ever since I changed the dbpath
in /etc/mongodb.conf
, MongoDB has not been starting automatically, nor using the new dbpath
. 自从我在
/etc/mongodb.conf
更改了dbpath
/etc/mongodb.conf
,MongoDB还没有自动启动,也没有使用新的dbpath
。 Prior to the change, MongoDB would be running when the computer started and I was able to simply run the command mongo
to get into the console or start my Ruby on Rails server with no issues. 在更改之前,MongoDB将在计算机启动时运行,并且我能够简单地运行命令
mongo
进入控制台或启动我的Ruby on Rails服务器而没有任何问题。
After I made the modification (in order to switch to a new drive with more space), the only way I can get everything to work is by manually running the command mongod --config /etc/mongodb.conf
. 在我进行修改之后(为了切换到具有更多空间的新驱动器),我可以通过手动运行命令
mongod --config /etc/mongodb.conf
来实现一切工作。 If I don't run that, it doesn't seem like the service is running and running without the --config
option give me the following error: ERROR: dbpath (/data/db/) does not exist.
如果我没有运行它,似乎服务没有运行并运行没有
--config
选项给我以下错误: ERROR: dbpath (/data/db/) does not exist.
even though the config file says nothing about data/db
. 即使配置文件没有提及
data/db
。
Some other notes: 其他一些说明:
/etc/mongodb.conf
, I moved all files out of /var/lib/mongodb
and into /home/nick/appdev/mongodb
. /etc/mongodb.conf
,我/etc/mongodb.conf
所有文件移出/var/lib/mongodb
并移入/home/nick/appdev/mongodb
。 root
to nick
. root
更改为nick
。 Tried changing it back, but it didn't seem to fix anything. A late follow up on the above question... 关于上述问题的后续跟进......
I had a similar issue after moving the db to an ebs on ec2. 将数据库移动到ec2上的ebs后,我遇到了类似的问题。
It turns out that just running mongod still directs the dbpath to /data/db/ (which exists). 事实证明,只运行mongod仍然将dbpath指向/ data / db /(存在)。
The /etc/mongodb.conf
is completely ignored unless specifically directed to. 除非特别指示,否则完全忽略
/etc/mongodb.conf
。
I manage to work around this by using the directive --config
or just the --dbpath
(both work) But was left wondering where does mongod takes it defaults from...?! 我设法通过使用指令
--config
或只是--dbpath
(两者都工作)来解决这个问题但是我想知道mongod默认从哪里开始......?!
I was unable to locate and override these defaults anywhere. 我无法在任何地方找到并覆盖这些默认值。 Anyone ?
任何人 ?
Note: I am really annoyed by this behaviour of mongod...This is just bad design,and bad documentation. 注意:我对mongod的这种行为感到非常恼火......这只是糟糕的设计和糟糕的文档。
It turns out that I needed to set the owner and group to mongodb
. 事实证明,我需要将所有者和组设置为
mongodb
。 When I transferred the files to the new directory, I had set the owner and group to my user account nick
and also tried root
, neither of which worked. 当我将文件传输到新目录时,我已将所有者和组设置为我的用户帐户
nick
并且还尝试了root
,这两种方法都不起作用。
To do so, here are the following commands: 为此,请执行以下命令:
sudo chown mongodb /home/nick/appdev/mongodb -R
sudo chgrp mongodb /home/nick/appdev/mongodb -R
To confirm that it worked, you can check the file permissions with: 要确认它是否有效,您可以使用以下命令检查文件权限:
ls -l /home/nick/appdev/mongodb
After checking all permission in the data, journal and log folders as suggested, my problem was solved by giving permission to a lock file in the /tmp folder 按照建议检查数据,日志和日志文件夹中的所有权限后,通过授予/ tmp文件夹中的锁文件权限解决了我的问题
sudo chown mongod:mongod mongodb-27017.sock
I was running it as a AWS Amazon Linux instance. 我将其作为AWS Amazon Linux实例运行。 I figured that out by executing as the mongod user as below, and then, researching the error code.
我通过执行下面的mongod用户计算出来,然后研究错误代码。 It might be useful for other troubleshooting.
它可能对其他故障排除很有用。
sudo -S -u mongod mongod -f /etc/mongod.conf
MongoDB 1.6 is very old and the latest production version is 2.2 , which contains a large amount of bug fixes and enhancements since 1.6. MongoDB 1.6非常老,最新的生产版本是2.2 ,自1.6以来,它包含大量的bug修复和增强功能。
Am I correct that you haven't installed 1.6 via a package manager such as yum or aptitude? 我是否通过包管理器(例如yum或aptitude)安装了1.6? I don't believe there are packages for 1.6 at present afaik.
我不相信目前有1.6的包装。 Therefore,
mongod
is behaving correctly as you have not started MongoDB with a control script. 因此,
mongod
表现正常,因为您没有使用控制脚本启动MongoDB。
Please see this link on configuration file options. 请参阅配置文件选项的此链接 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.