Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed MongoDB in an Ubuntu Server VM inside VMware using these instructions: Everything works fine, and I can access MongoDB at the regular port 27017


Now, I want to make a dummy replica set and another db instance for testing my app. I'm used to doing the following commands in four separate terminals on my local computer:

./mongod --port 27027 --dbpath ~/mongodb/solo
./mongod --port 27028 --dbpath ~/mongodb/rs0-0 --replSet rs0
./mongod --port 27029 --dbpath ~/mongodb/rs0-1 --replSet rs0
./mongod --port 27030 --dbpath ~/mongodb/rs0-2 --replSet rs0

How can I do this in the VM? I SSH into my VM, and after running the commands and closing my terminals (in OS X), they should still be running.

I tried:

service mongodb --port 27027 --dbpath ~/mongodb/solo
service mongodb ~/mongodb/solo/mongodb.conf

But both get the following error (with different contexts):

Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mongodb --config=~/mongodb/solo/mongodb.conf

The script you are attempting to invoke has been converted to an Upstart
job, but --config=~/mongodb/solo/mongodb.conf is not supported for Upstart jobs.

How do I get this working? First time working with Ubuntu as a server. Thanks.

Context - goal is to create my db in a VM to create some sort of lag while testing my app, but mostly so I can just suspend the VM instead of copying and pasting scripts into different terminals to setup MongoDB whenever I restart my laptop.

share|improve this question
up vote 1 down vote accepted

When you install using the Ubuntu package, it creates an upstart job and that is what you are starting/stopping with service on an Ubuntu system. Of course, it only starts one mongod and has one config by default. That upstart job can be found here (by default):


That is not to be confused with /etc/mongodb.conf which is the default location of the config file for the MongoDB service.

If you want to be able to start/stop the extra instances automatically or you want to have upstart manage them, then you just need to create duplicate jobs that point to different config files (or have different options specified in the job file itself). Start with taking a look at the file in init I mentioned above and then have a look here for more info on rolling your own upstart jobs:

The other option, of course, is to just invoke extra mongod instances directly. For example:

/usr/bin/mongod --fork --config=~/mongodb/solo/mongodb.conf

The --fork option (if not specified in the config file) is needed to fork to the background and not be killed when you log out and terminate the shell.

share|improve this answer
fork works perfectly. i don't really need upstart since it's just for testing and i never intend on shutting it on/off. thanks! – Jonathan Ong Dec 7 '12 at 21:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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