复制集的最佳实践 mongod 参数
我正在 mongoDB 上迈出第一步,以设置 HA 环境。我通过本教程运行: http: //www.mongodb.org/download/attachments/9830402/mongodb+replica+sets+intro.pdf 一切正常。
要为复制集启动 mongoDB 守护进程,您必须设置启动参数 --replSet
否,我需要在服务器启动时启动此守护进程,而不是每次运行以下命令“手动”重启后的时间: mongod --rest --replSet mongos
在服务器启动时启动此守护进程的一种方法是更改 /etc/init.d/mongodb
,如下所示
/sbin/startproc -u mongodb -g mongodb ${mongodb_BIN} --quiet \
--rest --replSet mongos \
-f "$mongodb_CONFIG"
: code>/etc/init.d/mongodb 位置正确吗?关键是,如果复制集的名称发生更改,我必须更改此文件。 或者有没有办法将这些启动参数放入配置文件中,例如 /etc/mongodb.conf
?
谢谢。
I'm on the first steps on mongoDB in order to set up an HA-environment. I run trough this tutorial: http://www.mongodb.org/download/attachments/9830402/mongodb+replica+sets+intro.pdf and everything works fine.
To start the mongoDB daemon for an replication-set, you have to set an start parameter --replSet <name>
No i need to start this daemon on server-startup instead of running the following command each time after reboot "by hand":mongod --rest --replSet mongos
One way to start this daemon on server-startup is to change the /etc/init.d/mongodb
, like this:
/sbin/startproc -u mongodb -g mongodb ${mongodb_BIN} --quiet \
--rest --replSet mongos \
-f "$mongodb_CONFIG"
Is /etc/init.d/mongodb
the right place? The point is, that I have to change this file, if the name of the replication set changes.
Or is there a way to put those start parameter to an configuration file, like /etc/mongodb.conf
?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在
mongod
命令行上指定的任何选项(-f
/--config
除外)也可以在加载的配置文件中指定<代码>--配置。我建议不要对初始化脚本进行太多更改,而是使用配置文件。 有:在你的情况下,你的配置文件中 请注意,由于 2.0 之前的 MongoDB 版本中配置文件的解析方式有一个怪癖,布尔选项(如
quiet
)将“=false”赋值视为 true。要禁用布尔参数,请在名称前面添加“no”,例如:而不是:
有关配置文件的更多信息,请参阅
附注:“mongos”是 MongoDB 的“分片路由器”组件的名称,因此您可能希望避免将其作为副本集名称。使用此名称作为副本集不会对 MongoDB 造成任何问题,但如果您稍后决定向系统添加分片,则可能会造成混乱。
Any options you can specify on the
mongod
command line (except-f
/--config
) can also be specified in the config file loaded with--config
. I'd recommend not changing the init script too much, and instead using the config file. In your case, you'd have:in your config file. Note that due to a quirk of how the config file is parsed in versions of MongoDB before 2.0, boolean options (like
quiet
) treat "=false" assignments as true. To disable a boolean parameter, prepend the name with "no" like:instead of:
For more on the config file, see http://www.mongodb.org/display/DOCS/File+Based+Configuration.
One side note: "mongos" is the name of the "sharding router" component of MongoDB, so you might want to avoid that as a replica set name. It won't cause any problems with MongoDB to use this name for a replica set, but it could get confusing if you decide at a later point to add sharding to your system.