How to run mongo db as service using non-default dbpath?
mongodb, ubuntu
Solution
This doesn't really have anything to do with a "service" it's down to the `mongod` (MongoDB's process name) parameters to use a `dbpath` other than `/data/db`
To find out what paramters are available to you can you simplely run ...
`$ mongod --help`
And you'll get a list of helpful parameters, there are also extensive docs explaining the various differant parameters you can use when starting up mongod ...
http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo
http://www.mongodb.org/display/DOCS/Command+Line+Parameters
A bit from the docs on your issue ...
Starting mongod
Default Data Directory, Default Port To start Mongo in default mode, where data will be stored in the /data/db directory (or c:\data\db on Windows), and listening on port 27017, just type
`$ ./mongod`
Alternate Data Directory, Default Port
To specify a directory for Mongo to store files, use the --dbpath option:
`$ ./mongod --dbpath /var/lib/mongodb/`
Note that you must create the directory and set its permissions appropriately ahead of time -- Mongo will not create the directory if it doesn't exist.
Alternate Port
You can specify a different port for Mongo to listen on for connections from clients using the --port option
`$ ./mongod --port 12345`
This is useful if you want to run more than one instance of Mongo on a machine (e.g., for running a master-slave pair).
Running as a Daemon
Note: these options are only available in MongoDB version 1.1 and later.
This will fork the Mongo server and redirect its output to a logfile. As with --dbpath, you must create the log path yourself, Mongo will not create parent directories for you.
`$ ./mongod --fork --logpath /var/log/mongodb.log --logappend`
Problem
When i try to start a service I get ``` ~$ sudo service mongodb start mongodb start/running, process 20221 ``` but it doesn't really start ~$ sudo service mongodb status mongodb stop/waiting it's probably because my dbpath is NOT default so how to start a m service using non-default dbpath