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
MongoDB runs as a standard program. You can start MongoDB from a command line by issuing the mongod command and specifying options. For a list of options, see the mongod reference. MongoDB can also run as a Windows service.
Mongos = MongoDB Shard Utility, the controller and query router for sharded clusters. Sharding partitions the data-set into discrete parts. Mongod = The primary daemon process for the MongoDB system. It handles data requests, manages data access, and performs background management operations.
To open up the MongoDB shell, run the mongo command from your server prompt. By default, the mongo command opens a shell connected to a locally-installed MongoDB instance running on port 27017 . Try running the mongo command with no additional parameters: mongo.
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
You can specify it with config file.
I found explanation here : http://blog.ajduke.in/2013/04/10/install-setup-and-start-mongodb-on-windows/
Using the config file
Instead of specifying command line option, we can specify same with use of file, which i call it here as config file Config file is just normal file, containing the parameters in the key=value form and each is on the every line of file In this, we basically provide path to file (which contains the configurations) as command line option as “-f” or “–config” Following is the snippet for the config file
shell > mongod --config I:\Servers\mongodb\config\mongodb.conf
And you get a file where you can specify dbpath :
#This is an example config file for MongoDB
#basic
dbpath = I:\Servers\mongodb\data
port = 27017
logpath = I:\Servers\mongodb\logs\mongo.log
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With