Install MongoDB on Ubuntu

Firstly, import the MongoDB public GPG key to require that the that the package is signed by the distributor.  I also was required to enable outbound connections on TCP service port 34898 to communicate with the key server using the hkp protocol:

sudo apt-key adv --keyserver hkp:// --recv 7F0CEB10

Now add the distribution for the package to the repository:

echo 'deb dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list

Finally, reload the repository and install the package:

sudo apt-get update
sudo apt-get install mongodb-10gen

Install MongoDB on CentOS

The following details the steps to deploy MongoDB on a CentOS using .rpm packages and basic configuration following deployment.

For deploying MongoDB on alternative platforms, check for deployment steps.

First of all we will need to configure the package management system to hold the configuration information for the MongoDB repository: by creating the following file ‘/etc/yum.repos.d/mongodb.repo ‘.

If you are installing MongoDB on a 64-bit architecture (which is recommended) add the below for the MongoDB repository:

name=MongoDB Repository

If you looking to install  32-bit version (which is not recommended  for production environments) use the below:

name=MongoDB Repository

Once the MongoDB repository has been configured, install the MongoDB daemon and tools packages.

yum install mongo-10gen mongo-10gen-server

By default, the install package configures MongoDB to use /etc/mongod.conf and the control script at /etc/rc.d/init.d/mongod. The instance will configure data files at ‘/var/lib/mongo’¬†¬†and its log files in ‘/var/log/mongo’¬†¬†and run using the security context of the mongod¬†user account.

In order to control the mongod process, run the following:

service mongod start
service mongod stop 
service mongod restart

You can verify that the mongod process has started successfully by checking f the log file /var/log/mongo/mongod.log.

If you require to ensure that MongoDB starts automatically following a reboot, run the following command:

chkconfig mongod on