MongoDB is a NoSQL database that is cross platform and is a document-based system. It can be easily installed in an Ubuntu server from the command-line. In Ubuntu 12.04 LTS repositories it’s current version is 2.0.4.

To install it in Debian / Ubuntu, open up a terminal enter the following command:

sudo apt-get install mongodb

Similarly for Arch based distributions you can issue the following command:

sudo pacman -S mongodb

Now for the fun part, the configuration.

Out of the box, MongoDB does not require any special configuration unless you want it to be able to support certain features like authentication, as it allows unauthenticated access by default so enabling authentication is recommended.

MongoDB’s service is started automatically in Ubuntu and you can start or restart it explicitly by issuing the following command:

sudo service mongodb start

In arch you will need to enable the service to run at boot explicitly:

sudo systemctl enable mongodb

and

sudo systemctl start mongodb

The configuration file for MongoDB is located at /etc/mongodb.conf on most systems.This configuration file has a simple syntax with each configuration variable on a separate line.

Some of the more important configuration file options are:

  1. dbpath – The location where your data is stored
  2. logpath – Where your server logs will be stored
  3. bind_ip – The IP address to bind to
  4. port – Port number to listen to
  5. noauth – It’s true by default and allows unauthenticated access to the MongoDB database. You should also set auth to true if you’re setting noauth to false.
  6. verbose – Sets the log level to verbose so more detail is shown in log files

MongoDB can run multiple instances on the same machine, provided different port number and database path (dbpath) is provided to it.

You can run multiple instances by specifying configuration parameters in separate files for each server instance.

For example:

mongod -f <path/to/configuration/file>