如何为 MongoDB 创建配置文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11600006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Create a configuration File For MongoDB
提问by Rob Schneider
I have installed mongodb for mac os through 10gen and I have gone through the documentation to do so. Everything seems fine apart from the configuration file. I can not see it in /etc/mongod.config. Do I have to manually create this config file? And if so how can I go about it?
我已经通过 10gen 为 mac os 安装了 mongodb,并且我已经阅读了相关文档。除了配置文件之外,一切似乎都很好。我在 /etc/mongod.config 中看不到它。我必须手动创建这个配置文件吗?如果是这样,我该怎么办?
cheers
干杯
采纳答案by Stennie
Unless you have installed a packaged version of MongoDB (for example, using Homebrew or Mac Ports) you will have to create a config file manually, or just pass the appropriate command line parameterswhen starting up MongoDB.
除非您安装了 MongoDB 的打包版本(例如,使用Homebrew 或 Mac Ports),否则您必须手动创建配置文件,或者在启动 MongoDB 时只传递适当的命令行参数。
If you want a commented example of a config file to start with, the mongodb.confin the Debian/Ubuntu package should be a good starting point. Important options to check are the dbpath
and logpath
which will likely be different for you.
如果你想要一个配置文件的注释示例开始,Debian/Ubuntu 包中的mongodb.conf应该是一个很好的起点。要检查的重要选项是dbpath
和logpath
对您来说可能会有所不同。
It would also be worth looking at the Homebrew mongodb formulawhich includes setting up a LaunchAgent script to manage the mongod service.
还值得查看Homebrew mongodb 公式,其中包括设置 LaunchAgent 脚本来管理 mongod 服务。
回答by Addison
The default path for brew installed mongodb on Mac OS X is /usr/local/etc/mongod.conf
在 Mac OS X 上 brew 安装 mongodb 的默认路径是 /usr/local/etc/mongod.conf
回答by Adam Comerford
Yes, unless you install via a package manager (like apt or yum on Linux) you have to create this manually. Then, When you start mongod you simply need to specify where the config file is, for example:
是的,除非您通过包管理器(如 Linux 上的 apt 或 yum)安装,否则您必须手动创建它。然后,当您启动 mongod 时,您只需指定配置文件的位置,例如:
./mongod -f /path/to/mongod.conf
For how that file should look, just take a look here:
有关该文件的外观,请看这里:
http://docs.mongodb.org/manual/reference/configuration-options/
http://docs.mongodb.org/manual/reference/configuration-options/
You can also see the aforementioned Linux config files from the packages on github:
您还可以从 github 上的软件包中看到上述 Linux 配置文件:
https://github.com/mongodb/mongo/blob/master/rpm/mongod.conf
https://github.com/mongodb/mongo/blob/master/rpm/mongod.conf
https://github.com/mongodb/mongo/blob/master/debian/mongodb.conf
https://github.com/mongodb/mongo/blob/master/debian/mongodb.conf
回答by LineDrop
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:
如果你安装了没有 Homebrew 的 MongoDB,即直接从 MongoDB 下载中心下载了 TGZ 包,你可以添加配置文件:
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 postabout installing MongoDB Community Edition directly from the TGZ archive.
我写了一篇关于直接从 TGZ 存档安装 MongoDB 社区版的帖子。