34

我已经通过 10gen 为 mac os 安装了 mongodb,并且我已经阅读了文档来执行此操作。除了配置文件之外,一切似乎都很好。我在 /etc/mongod.config 中看不到它。我是否必须手动创建此配置文件?如果是这样,我该怎么办?

干杯

4

4 回答 4

85

Mac OS X 上 brew 安装的 mongodb 的默认路径是/usr/local/etc/mongod.conf

于 2013-01-28T16:59:49.577 回答
27

除非您安装了 MongoDB 的打包版本(例如,使用Homebrew 或 Mac Ports),否则您必须手动创建配置文件,或者在启动 MongoDB 时传递适当的命令行参数。

如果您想从一个配置文件的注释示例开始,Debian/Ubuntu 包中的mongodb.conf应该是一个很好的起点。要检查的重要选项是dbpath并且logpath可能对您不同。

还值得一看Homebrew mongodb 公式,其中包括设置 LaunchAgent 脚本来管理 mongod 服务。

于 2012-07-22T12:24:40.617 回答
11

是的,除非您通过包管理器(如 Linux 上的 apt 或 yum)安装,否则您必须手动创建它。然后,当您启动 mongod 时,您只需指定配置文件的位置,例如:

./mongod -f /path/to/mongod.conf

对于该文件的外观,只需在此处查看:

http://docs.mongodb.org/manual/reference/configuration-options/

您还可以从 github 上的包中查看上述 Linux 配置文件:

https://github.com/mongodb/mongo/blob/master/rpm/mongod.conf

https://github.com/mongodb/mongo/blob/master/debian/mongodb.conf

于 2012-07-22T12:23:20.247 回答
0

In the case you installed MongoDB without Homebrew, i.e. downloaded the TGZ package directly from MongoDB Download Center, you will can add the configuration file:

sudo nano /etc/mongod.conf

Please use only spaces (no tabs) in the file and leave a space after the key. For example:

security:
  authorization: enabled
net:
  port: 27017
  bindIp: 0.0.0.0

And then run the instance with the configuration flag:

mongod -f /etc/mongod.conf

I wrote a post about installing MongoDB Community Edition directly from the TGZ archive.

于 2020-05-04T20:29:07.870 回答