In this blog posting we will see how to install MongoDB on a Linux distribution. MongoDB is supported for Linux, Mac, Windows and Solaris.

Linux distribution

First, determine your Linux distribution in order to download the appropriate MongoDB binaries.

cat /proc/version

MongoDB is supported on the following operating systems:

Platform 3.2 3.0 2.6
Amazon Linux × × ×
Debian 7 × × ×
Fedora 8+ ×
RHEL/CentOS 6.2+ × × ×
RHEL/CentOS 7.0+ × × ×
SLES 11+ × × ×
Solaris 64-bit × × ×
Ubuntu 12.04 × × ×
Ubuntu 14.04 × × ×
Microsoft Azure × × ×
Windows Vista/Server 2008R2/2012+ × × ×
OSX10.7+ × × ×

MongoDB recommends the following OS for production environments:

  • Amazon Linux
  • Debian 7.1
  • Red Hat / CentOS 6.2+
  • SLES 11+
  • Ubuntu LTS 12.04
  • Ubuntu LTS 14.04
  • Windows Server 2012 & 2012 R2

You always should use 64-bit builds for production environment. 32-bit build were deprecated from MongoDB.

Binary installation

Download and extract, the latest (3.2 release)  stable release from the MongoDB website. In this blog we are going to install the 3.0.2 release.

Software Directory Creation:

To start a MongoBD server, you must create the data/db directory to store data files. To manage your installation, dbi services provides you some best practices to properly install MongoDB on your system.
Based on the Oracle and MySQL installation dbi services has implemented an Optimal Flexible Architecture (OFA) for MongoDB.

As root:
mkdir /u00/app/mongodb
mkdir /u00/app/mongodb/product

mkdir /u00/app/mongodb/admin/
mkdir /u00/app/mongodb/admin/mongod1/
mkdir /u00/app/mongodb/admin/mongod1/etc/
mkdir /u00/app/mongodb/admin/mongod1/log/

mkdir /u01/app/mongodbdata/mongod1/

Check if you have the permissions to all of this directories. If not, add the permissions:

sudo chown -R username:group /u00/app/mongodb/
sudo chown -R username:group /u01/mongodbdata/

Move the MongoDB folder into the product directory:

mv mongodb-linux-x86_64-ubuntu1204-3.0.2/ /u00/app/mongodb/product

To start MongoDB by command line, specify the data path and the log file path:

./mongod --dbpath /u01/mongodbdata/mongod1/ --logpath /u00/app/mongodb/admin/mongod1/log/mongod.log --fork

about to fork child process, waiting until server is ready for connections.
forked process: 7785
child process started successfully, parent exiting

By default MongoDB start on localhost and listen on the port 27017, if you want to change it, use the –-host and –-port options. Use the –-help to see all available options for mongod.

You can also, add binaries to the system path by adding the following lines to your bash.rc file:

PATH=$PATH:/u00/app/mongodb/product/mongodb-linux-x86_64-ubuntu1204-3.0.2/bin source /etc/bash.bashrc

Binary description

Below you will find a description of all available binaries on the MongoDB Community release:

Components:

  • mongod:         Database process
  • mongo:           Database shell (javascript)
  • mongos:         Sharding controller

Utilities:

  • mongodump:   Dump tool for backups, snapshots, etc …
  • mongorestore: Restore a MongoDB Dump
  • mongoimport: Import from JSON or CSV
  • mongoexport:  Export a single collection to test
  • mongostat:       Show performance statistics
  • mongofiles:      Utility for putting and getting files from MongoDB GridFS

MongoDB Shell

Connect to the mongo shell by launching the ./mongo binary:

./mongo
MongoDB shell version: 3.0.2
connecting to: test

Show all databases:

> show dbs
local  0.078GB

Create a new database:

> use test switched to db test

 

In a next blog we will see how to insert, delete, update and read data from the MongoDB Shell.

Conclusion:

The installation of MongoDB is very easy and everyone can quickly install and test it in its own working environment. The work of dbi services here is to provide an extremely professional installation with the best practices for your production environment. In example,  the Optimal Flexible Architecture for MongoDB is one of the best practices.


Thumbnail [60x60]
by
DevOps