Install Mongodb on CentOS, RHEL, Debian, Ubuntu

Overview

MongoDB is an open-source, document-oriented database designed for ease of development and scaling. Some of mongodb features include high performance, high availability. document-oriented, easy scalability, rich query language. Source http://www.mongodb.org

Install Mongodb on CentOS, RHEL, Debian, Ubuntu

On CentOS, RHEL

Add 10gen Repository for mongodb


# vi /etc/yum.repos.d/mongodb.repo

Append the following to it
For x86_64 bit CentOS/RHEL


[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0

For i386 32 bit CentOS/RHEL


[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0

Install mongodb server and client and other dependencies


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

On Debian, Ubuntu

Add GPG key


$ sudo su -
# apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Create a file under sources.list and include the following line for the 10gen repository.


# vi /etc/apt/sources.list.d/mongo-10gen.list

On Ubuntu system, append the following
Append the following to it


deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

On Debian system, append the following
Append the following to it


deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen

Install mongodb and chkconfig


# apt-get update
# apt-get install mongodb-10gen chkconfig

Start mongodb


# /etc/init.d/mongod start
# chkconfig mongod on

Enter mongo shell by executing mongo on the terminal

# mongo
MongoDB shell version: 2.2.2
connecting to: test
>

Click here for basic commands mongodb show tables, views, databases, create users and more.