2

I have the following services on a single shard server: sudo mongod --dbpath /data/db/ --port 31001 sudo mongod --configsvr --dbpath /data/configdb/ --port 21001

The same server is using for shard and config.
for now I am testing the environment so I am running these rows manually.
I want to run it as a service. I did not event tried it, adding dbpath twice to the config file will not do the work, can you suggest please a config in order to make these lines run as a service?
thanks

3
  • You want to know how to create a config file with those options?
    – joao
    Commented Mar 9, 2014 at 7:25
  • @joao, yes, but as I am looking at question I see that I am missing an important part. How do I keep the default ubuntu service and run another one for the config service. I mean, mongo is comming with one mongod service, and here I need 2. thanks
    – SexyMF
    Commented Mar 9, 2014 at 11:20
  • Are you in production or testing once you set these up to run as daemons as opposed to interactive shell processes? Where will you log the server output? Do you have a preferred method to run other services on ubuntu or is this a single purpose VM/appliance situation?
    – bmike
    Commented Aug 31, 2015 at 17:33

2 Answers 2

1

An easy way to achieve that is to use cron's @reboot feature:

> crontab -e -u mongodb
@reboot /usr/bin/mongod --configsvr --dbpath /data/configdb/ --port 21001 --logpath /var/log/mongodb/configsvr.log --fork
@reboot /usr/bin/mongod --shardsvr --dbpath /data/db/ --port 31001 --logpath /var/log/mongodb/mongod.log --fork

However, you have to make sure that /etc/security/limits.conf holds the correct values.

0

If you want to run multiple MongoDB services on the same host, you just need to create separate service definitions and configuration files for each service.

As a starting point I would look at the standard mongod.upstart script in Github and adapt a version to start your config server.

I would also note that for a production system you should always deploy three config servers. If you lose your single config server, you will also lose the metadata for your sharded cluster.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.