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.
Any options you can specify on the
mongodcommand 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.