Installation steps of MongoDB

Installation steps of MongoDB

Installation on various operating systems is discussed below.

Installing on Linux

For easy installation, MongoDB provides packages for popular Linux distributions as rpm packages for Red Hat Enterprise, CentOS, Fedora and related Linux systems and deb package for Ubuntu Linux systems.

.deb or .apt based installation – It involves configuring the Package Management System (APT) The Debian package management tools (i.e. dpkgandapt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys.

Import MongoDB PGP key. Issue the following command to add the MongoDB public GPG Key to the system key ring.

sudo apt-key adv –keyserver keyserver.ubuntu.com –recv 7F0CEB10

Create a sources.list file for MongoDB. Create a/etc/apt/sources.list.d/mongodb.list file

echo ‘deb http-//downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen’ | sudo tee /etc/apt/so

Reload local package database. Issue the following command to reload the local package database

sudo apt-get update

Install Packages Issue the following command to install the latest stable version of MongoDB

sudo apt-get install mongodb-10gen

When this command completes, we have successfully installed MongoDB!

We can use themongodb-10genpackage to install previous versions of MongoDB. To install a specific release, append the version number to the package name, as in the following example

apt-get install mongodb-10gen=2.2.3

This will install the 2.2.3 release of MongoDB.

.rpm based installation – It involves the following steps

  • Download the Latest Release – In a system shell, download the latest release, as

curl -O http://downloads.mongodb.org/linux/mongodb-linux-i686-2.4.9.tgz

  • User may optionally specify a different version to download.
  • Extract MongoDB from Archive – Extract the files from the downloaded archive.

tar -zxvf mongodb-linux-i686-2.4.9.tgz

  • Copy MongoDB to Target Directory – Copy the extracted folder into another location, such as mongodb.

mkdir -p mongodb

cp -R -n mongodb-linux-i686-2.4.9/ mongodb

  • Configure Search Path – To ensure that the downloaded binaries are in yourPATH, User can modify yourPATH and/or create symbolic links to the MongoDB binaries in your /usr/local/bindirectory (/usr/local/binis already in yourPATH). The MongoDB binaries are in the bin/directory within the archive.
  • Run MongoDB

Install on OS X

Starting in version 2.4, MongoDB only supports OS X versions 10.6 (Snow Leopard) on Intel x86-64 and later. MongoDB is available through the popular OS X package manager Homebrew or through the MongoDB Download site.

Homebrew installs binary packages based on published “formulae”. The following commands will update brew to the latest packages and install MongoDB. In a terminal shell, use the following sequence of commands to update ‘‘brew’’ to the latest packages and install MongoDB

brew update

brew install mongodb

Use the following command to build MongoDB with SSL support

brew install mongodb –with-openssl

The steps for manual installation are as

Download the Latest Release In a system shell, download the latest release for 64-bit OS X.

curl -O http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.4.9.tgz

Extract MongoDB From Archive Extract the files from the downloaded archive.

tar -zxvf mongodb-osx-x86_64-2.4.9.tgz

Copy the extracted folder into another location, such as mongodb.

mkdir -p mongodb

cp -R -n mongodb-osx-x86_64-2.4.9/ mongodb

To ensure that the downloaded binaries are in yourPATH, modify yourPATHand/or create symbolic links to the MongoDB binaries in your /usr/local/bindirectory (/usr/local/binis already in yourPATH). Find the MongoDB binaries in thebin/directory within the archive.

Run MongoDB

Installing on Windows

Installing MongoDB on Windows involves the following steps as

  • Download the latest production release of MongoDB from the MongoDB downloads
  • Extract the downloaded archive.
  • In Windows Explorer, find the MongoDB download file, typically in the default downloads directory.
  • Extract the archive to C:\by right clicking on the archive and selecting Extract All and browsing to C:\.
  • Move the MongoDB directory to another location. For example, to move the directory to C:\mongodb directory as
  • Go Start Menu>All Programs>Accessories.
  • Right click Command Prompt, and select Run as Administrator from the popup menu.
  • In the Command Prompt, issue the following commands

cd \

move C:\mongodb-win32-* C:\mongodb

  • Run MongoDB

Get industry recognized certification – Contact us

Menu