blogspot visit counter

Friday, 15 March 2013

Install Mongo on CentOS,Fedora, Ubuntu & Debian

Install MongoDB 2.0.4 on RHEL CentOS Fedora Ubuntu & Debian

Install MongoDB 2.0.4 on RHEL CentOS Fedora Ubuntu & Debian

This howto guide shows how to install MongoDB 2.0.4 on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16/15/14/13/12, Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian using MongoDB own YUM repositories for RHEL, CentOS and Fedora and apt-get for Ubuntu and Debian.

What is MongoDB?

MongoDB (from "humongous") is an open source scalable, high-performance and schema-free document-oriented NoSQL database system written in C++. MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide structured schemas and powerful queries).

MongoDB Features

  1. Document-oriented storage (the simplicity and power of JSON-like data schemas)
  2. Dynamic queries
  3. Full index support, extending to inner-objects and embedded arrays
  4. Query profiling
  5. Fast, in-place updates
  6. Efficient storage of binary data large objects (e.g. photos and videos)
  7. Replication and fail-over support
  8. Auto-sharding for cloud-level scalability
  9. MapReduce for complex aggregation
  10. Commercial Support, Training, and Consulting

Why MongoDB?

  1. Document-oriented
    1. Documents (objects) map nicely to programming language data types
    2. Embedded documents and arrays reduce need for joins
    3. Dynamically-typed (schemaless) for easy schema evolution
    4. No joins and no multi-document transactions for high performance and easy scalability
  2. High performance
    1. No joins and embedding makes reads and writes fast
    2. Indexes including indexing of keys from embedded documents and arrays
    3. Optional streaming writes (no acknowledgements)
  3. High availability
    1. Replicated servers with automatic master failover
  4. Easy scalability
    1. Automatic sharding (auto-partitioning of data across servers)
      1. Reads and writes are distributed over shards
      2. No joins or multi-document transactions make distributed queries easy and fast
    2. Eventually-consistent reads can be distributed over replicated servers
  5. Rich query language
Install MongoDB 2.0.4 on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12, Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian

How to Install MongoDB 2.0.4 RHEL, CentOS and Fedora

Step 1: Adding 10gen MongoDB Repository

Add 10gen Mongodb-repo (yum-installable RPM packages) on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12 for x86 and x86_64 platforms.

For all 32-bit RPM-based distros with yum, put this at /etc/yum.repos.d/10gen.repo:
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/
redhat/os/i686
gpgcheck=0
For all 64-bit RPM-based distros with yum, put this at /etc/yum.repos.d/10gen.repo:
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/
redhat/os/x86_64
gpgcheck=0

Step 2: Installing MongoDB 2.0.4

Installing MongoDB Database Server on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12 for x86 and x86_64 platforms using YUM.
yum install mongo-10gen mongo-10gen-server
Note: for users upgrading from older (pre-2/2011) packaging scheme, it may be necessary to uninstall your existing "mongo-stable", "mongo-stable-server", "mongo-unstable", "mongo-unstable-server" packages before installing the latest mongo-10gen, mongo-10gen-server pacakges.

Step 3: Configure MongoDB Database Server

Open and edit /etc/mongod.conf file with VI Editor. Verify and set basic settings, before starting MongoDB Database Server.
vi /etc/mongod.conf
logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo

Step 4: Starting MongoDB Database Server

/etc/init.d/mongod start
## OR ##
service mongod start

Step 5: Testing MongoDB Database Server

Testing with MongoDB command line client.
mongo

Step 6: Executing MongoDB Basic Commands

> show dbs
> show collections
> show users
> use <db name>

Step 7: Starting & Stopping MongoDB

Here is a quick reference to the commands that control the execution of the mongod server process:
service mongodb status 
service mongodb stop
service mongodb start
service mongodb restart
## OR ##
/etc/init.d/mongod status
/etc/init.d/mongod stop
/etc/init.d/mongod start
/etc/init.d/mongod restart

Step 8: Opening MongoDB Port on Firewall

Open file /etc/sysconfig/iptables and add the following line at the bottom and restart iptables.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 
-j ACCEPT
/etc/init.d/iptables restart
## OR ##
service iptables restart

Step 9: Testing MongoDB Remote Connection

mongo serverip:port/databasename
## Example ##
mongo 192.168.1.21:27017/ravisaive

How to Install MongoDB 2.0.4 on Ubuntu and Debian

Step 1: Adding 10gen MongoDB source.list

The 10gen package contains the latest mongoDB version, add below lines at the bottom of the file “/etc/apt/sources.list” on Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian.

For Ubunut, put these below lines to “/etc/apt/sources.list”:
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart 
dist 10gen
For Debian, put these below lines to “/etc/apt/sources.list”:
deb http://downloads-distro.mongodb.org/repo/debian-sysvinit 
dist 10gen

step 2: Adding GPG Key

10gen package required GPG key, import it:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 
7F0CEB10

step 3: Insalling MongoDB

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

step 4: Starting MongoDB

sudo status mongodb
sudo stop mongodb
sudo start mongodb
sudo restart mongodb

step 5: Testing MongoDB

To verify it, just connect it with “mongo
mongo
In case you're facing any difficulties while setting up MongoDB Database Server, please share with us via comment.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...