复制集的最佳实践 mongod 参数

发布于 2024-12-31 23:16:23 字数 834 浏览 2 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沩ん囻菔务 2025-01-07 23:16:23

您可以在 mongod 命令行上指定的任何选项(-f/--config 除外)也可以在加载的配置文件中指定<代码>--配置。我建议不要对初始化脚本进行太多更改,而是使用配置文件。 有:

rest=true
replSet=mongos
quiet=true

在你的情况下,你的配置文件中 请注意,由于 2.0 之前的 MongoDB 版本中配置文件的解析方式有一个怪癖,布尔选项(如 quiet)将“=false”赋值视为 true。要禁用布尔参数,请在名称前面添加“no”,例如:

nojournal=true

而不是:

journal=false

有关配置文件的更多信息,请参阅

附注:“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:

rest=true
replSet=mongos
quiet=true

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:

nojournal=true

instead of:

journal=false

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文