3/27/15

How to Install MongoDB 3.0 on CentOS/RHEL & Fedora


MongoDB (named from “huMONGOus“) is a full flexible index support and rich queries database. Its is a NoSQL database. MongoDB provides large media storage with GridFS. Clickhere for more details about mongoDB.
MongoDB has released new stable version 3.0 with lots of major enhancements. This tutorial will help you to install MongoDB 3.0.X on CentOS, RHEL and Fedora Systems.
Key Features of This Release:-
  • Introduces a pluggable storage engine API that allows third parties to develop storage engines
  • Introduces support for the WiredTiger storage engine.
  • Increased more consistency on updating and inserting data
  • The MMAPv1 storage engine adds support for collection-level locking
  • In MongoDB 3.0, replica sets can have up to 50 members.
  • Various enhancements for clusters.
  • Read more…

Step 1: Add MongoDB Yum Repository

Add following content in yum repository configuration file /etc/yum.repos.d/mongodb.repo as per your required MongoDB version and system architecture. For this article we are using MongoDB 3.0 repository.

For MongoDB 3.0.X

For 64bit Systems:
[MongoDB]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1

For MongoDB 2.6.X

For 64bit Systems:
[MongoDB]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
For 32bit Systems:
[MongoDB]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/
gpgcheck=0
enabled=1

Step 2: Install MongoDB

Lets use yum package manager to install mongodb-org package, it will automatically install all its dependencies. To install any specific revision of mongodb specify package name with version like mongodb-org-3.0.0. Following command will install latest stable version available.
# yum install mongodb-org
...
...
Dependencies Resolved

====================================================================== ======
 Package                          Arch      Version        Repository   Size
====================================================================== ======
Installing:                                                            
 mongodb-org                      x86_64    3.0.0-1.el7    MongoDB     4.5 k
Installing for dependencies:                                           
 mongodb-org-mongos               x86_64    3.0.0-1.el7    MongoDB     3.8 M
 mongodb-org-server               x86_64    3.0.0-1.el7    MongoDB     8.1 M
 mongodb-org-shell                x86_64    3.0.0-1.el7    MongoDB     4.0 M
 mongodb-org-tools                x86_64    3.0.0-1.el7    MongoDB      31 M
                                                                       
Transaction Summary                                                    
====================================================================== ======
Install  1 Package (+4 Dependent packages)

Total download size: 47 M
Installed size: 147 M
Is this ok [y/d/N]: y
...
...

Step 3: Start MongoDB

Package mongodb-org-server provided MongoDB init script, Use that script to start service.
# /etc/init.d/mongod restart
Configure MongoDB to auto start on system boot.
# chkconfig mongod on

Step 4: Check MongoDB Version and Test Setup

Use following command to check installed mongodb version
[root@tecadmin ~]#  mongo --version

MongoDB shell version: 3.0.0
Connect MongoDB using command line and execute some test commands for checking proper working.
[root@tecadmin ~]#  mongo

> use mydb;
> db.test.save( { a: 1 } )
> db.test.find()

  { "_id" : ObjectId("54fc2a4c71b56443ced99ba2"), "a" : 1 }
Congratulation’s You have successfully installed mongodb server on your system. For practice only you may use MongoDB browser shell.

How to Install JAVA 8 (JDK 8u40) on CentOS/RHEL 7/6/5 and Fedora

After a long wait, finally Java SE Development Kit 8 is available to download. JDK 8 has been released on Mar,18 2014 for general availability with the many featured enhancements. You can find all the enhancements in JDK 8 here.
This article will help you to Install JAVA 8 (JDK 8u40) or update on your system. Read instruction carefully for downloading java from Linux command line. To Install Java 8 in Ubuntu and LinuxMint read This Article.

Downloading Latest Java Archive

Download latest Java SE Development Kit 8 release from its official download page or use following commands to download from shell.

For 64Bit

# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u40-b25/jdk-8u40-linux-x64.tar.gz"

# tar xzf jdk-8u40-linux-x64.tar.gz

For 32Bit

# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u40-b25/jdk-8u40-linux-i586.tar.gz"

# tar xzf jdk-8u40-linux-i586.tar.gz
Note: If Above wget command doesn’t not work for you watch this example video  to download java source archive using terminal.

Install Java with Alternatives

After extracting archive file use alternatives command to install it. alternatives command is available in chkconfig package.
# cd /opt/jdk1.8.0_40/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_40/bin/java 2
# alternatives --config java


There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /opt/jdk1.8.0/bin/java
 + 2           /opt/jdk1.8.0_25/bin/java
   3           /opt/jdk1.8.0_40/bin/java

Enter to keep the current selection[+], or type selection number: 3

At this point JAVA 8 has been successfully installed on your system. We also recommend to setup javac and jar commands path using alternatives
# alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_40/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_40/bin/javac 2
# alternatives --set jar /opt/jdk1.8.0_40/bin/jar
# alternatives --set javac /opt/jdk1.8.0_40/bin/javac 

Check Installed Java Version

Check the installed version of java using following command.
root@tecadmin ~# java -version

java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

Configuring Environment Variables

Most of java based application’s uses environment variables to work. Set the Java environment variables using following commands
  • Setup JAVA_HOME Variable
  • # export JAVA_HOME=/opt/jdk1.8.0_40
    
  • Setup JRE_HOME Variable
  • # export JRE_HOME=/opt/jdk1.8.0_40/jre
    
  • Setup PATH Variable
  • # export PATH=$PATH:/opt/jdk1.8.0_40/bin:/opt/jdk1.8.0_40/jre/bin

FIND US ON FACEBOOK

FIND US ON Twitter