Here's the easier way (trivial if your configs are templates generated by configuration management):
- Add pidfilepath to all of your mongodb.conf files, ensuring the pidfilepath is different for each instance you want to run. (IMO: This should be a default in the config file.)
- You should already have different config files since you'll need to change the value of the listen port and db directory. If you specify all of this on the command line you're a bad person and should feel bad about yourself.
- Edit /etc/init/mongodb.conf and add "-p /pidfilepath/from/config/file.pid" to the start-stop-daemon arguments, before the --exec
- Copy the init file for each mongod instance you want to run, adjust the pidfile to te correct
- Run stuff
Why would you want to do this? In my case I want to run a replicaset arbiter on a node also running a database so I can test the setup teardown of replicas in vagrant without having to create a third machine. In other cases, I want to use a separate mongo database on the same machine my 3rd arbiter is running on.