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 CentOSRHEL 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

3/20/15

Top 10 Linux Distributions

List Of Top Linux Distributions In My Point Of View

Nowadays, there are a huge number of distributions, versions of the operating system within Linux which is not clear for newcomer so they don’t know which one fits their need. The most popular known distribution is Ubuntu, but there are many others, each one of them offers some variant on the basic Linux theme.
Choosing the right distribution known also as “distro” for your business isn’t enough clear. This choice depends particularly on several key factors (skills, software, hardware, support…). It is also good to know how to make difference between the current distros.
The top 10 Linux distributions will be described in this article.

1. Ubuntu

Let’s start by the famous one, Ubuntu. It is is an open source operating system (not to be confused with the term “free software”) sponsored by Canonical company and a trademark registered by the same company. Based on the Debian Linux distribution, this operating system is composed of several open source softwares, and is available for free, even for businesses. Moreover, it is the most popular distro, garnering by more than 2000 hits per day on the Distrowatch site compared with 1500 for Fedora.
ubuntu
Ubuntu is also notable for its ease of use and its inclusion of a migration assistant for Windows users and support for the latest technologies. It’s also worth understanding that Ubuntu is available in various remixes and spin-off sub-distros targeted at specific niches, such as Kubuntu, Xubuntu and Lubuntu. Most of these differ primarily by offering a desktop environment other than Ubuntu’s standard GNOME.

2. Fedora

Fedora, formerly Fedora Core is a GNU / Linux distribution built upon the RPM system, developed by the Fedora Project and supported by Red Hat. This distribution is intended to be a complete and general operating system composed entirely by free software. Indeed, Fedora derives from the Red Hat Linux distribution, and it is intended to replace it (especially for noncommercial use). It uses the GNOME desktop environment by default, but users can easily switch to KDE, Xfce, LXDE, MATE and Cinnamon, among others. Custom variations of Fedora, known as Fedora spins, are available for users with particular needs
ferdoreThe Fedora Project began at the end of 2003, when Red Hat Linux has neglected to sale its products to the public. Red Hat has led users wlinithin professional use of Red Hat Linux to Red Hat Enterprise Linux (RHEL), while users into domestic use were redirected to Fedora. Since RHEL is the only Linux distribution for which Red Hat provides official assistance.
With the first release of Fedora, Red Hat has launched a trend that was then followed by many Linux distribution vendors: those to create a community distribution whose commercial distribution could be based on.
Fedora also offers a six-month release schedule, and its security features are excellent. While some have viewed it as a cutting-edge distro for the Linux “hobbyist,” I think improvements over the years and widespread popularity have combined to make it a good choice for newer Linux users as well.

3. Linux Mint

Linux Mint is a 32- and 64-bit Linux distribution for desktop computers, based on either Ubuntu or Debian. Its stated aim is to be a modern, elegant and comfortable operating system which is both powerful and easy to use. It provides full out-of-the-box multimedia support by including some proprietary software such as Adobe Flash. Mint’s motto is from freedom came elegance. New versions of the Ubuntu-based Linux Mint have been released approximately every six months. The first release, named “Ada”, was released in 2006. The 17th release, “Qiana”, was released on May 31, 2014. Support for older releases usually ends shortly after the next version is released, but there have been released with long-term support, including the current release, v17.x, which will be supported for five years, until April 2019.
linuxminit
Mint enjoys a well-deserved reputation for ease of use, so it’s another good one for beginners. It also includes some proprietary multimedia codecs that are often absent from larger distributions, thereby enhancing its hardware compatibility. Mint doesn’t have a fixed release schedule, but typically a new version comes out shortly after each stable Ubuntu release.

4. OpenSUSE

OpenSUSE is an important Linux distribution and its origin is German. It is a community supported by SUSE distribution and other sponsors. It is the successor to the historic “SUSE Linux Professional” and today serves as the basis for SUSE Linux Enterprise products.
oensuse
It was aiming to be a great beginner distro and something that appeals to experienced Linux users. It comes with YAST, an administration program that controls installations, package management and more. New versions of openSUSE are released every 8 months, supporting many languages – each release is provided with security updates for a period of 18 months.
OpenSUSE is a completely open source system. It contains therefore not proprietary drivers or codecs to support most closed multimedia formats. However, it is possible to simply install the packages to take advantage of these materials, as well as drivers for ATI or nVidia.

5. PCLinuxOS

PCLinuxOS is a user-friendly Linux distribution with out-of-the-box support for many popular graphics and sound cards, as well as other peripheral devices. This distribution makes it easy to install drivers, get Office software, edit photos, get online and start using multimedia. It also makes it easy to do snapshot backups. The intuitive system configuration tools include Synaptic for package management, Addlocale to add support with several languages, Getopenoffice to install the latest OpenOffice.org, and Mylivecd to create a customized live CD.
pc
Rather than GNOME, PCLinuxOS uses the KDE desktop environment and is essentially a lighter-weight version of Mandriva. This distribution has a good support for graphics drivers, browser plugins and media codecs. Indeed, it could be a good choice for beginners. But you need to know that currently there is no 64-bit version of this software.

6. Debian

Debian is a free operating system for your computer. It is currently known as one from the most important available distros. It serves as the foundation for Ubunto, many users consider it as the best one suited for those experienced with Linux. With Debian, you have the possibility to use all open-source components which is a very good thing. To know also that Debian has a slow release cycle, with a period of 1 to 3 years.
debain
Debian is an older Linux distribution (released in 1993) which comes with the GNOME desktop environment by default.. However, it’s also available for FreeBSD and several effort has been made to make it available also to support other kernels, such as the Hurd. With over than preloaded 37 500 packages, Debian prides itself.

7. Sabayon/Gentoo

Sabayon Linux is a GNU / Linux distribution based on Gentoo. Unlike Gentoo which installs all or part of the systems from the source code. Sabayon installs the base system from precompiled packages.
ganeto
Sabayon Linux is a ready distribution for use, it means that it includes the basic proprietary drivers of different graphic and wireless cards, audio codecs – video, flash, java, etc. in order that the system can work without having to install them after the installation. It is thus not completely a free tool.

8. Arch Linux

Arch Linux is another Linux distribution which is created by Judd Vinet that emphasizes simplicity (according to the KISS principle). Judd has been inspired by another Linux down known as Crux Linux. Arch Linux was designed to be the perfect operating system for advanced users. His philosophy without artifice or configuration tools is very similar to Slackware in the sense that it requires a certain level of knowledge to be installed, but it is nevertheless easy to maintain.
archlinux
The installation packages goes through ABS: Arch Linux Build System, a system looking like the ports BSD. ABS allows you to install precompiled binary packages or build a package from its source.

9. Puppy Linux

Puppy Linux is a Linux distribution available in Live CD created by Barry Kauler. With very small size (about 100 MB, 170 MB for the latest version), this distribution is designed to be lightweight, reliable and easy to use while retaining maximum functionality.
putptThe entirety of operating system and all programs can be loaded into RAM, which allows you to remove the boot media after initialization. Puppy Linux provides a package manager (Puppy package manager) that facilitates the installation of new software. Like big Linux distributions, this interface has installed and installable packages and automates installation / uninstallation, avoiding the often confusing process of manual installation (configure, make, make install …). A list of official packages that were created and tested for Puppy Linux, from source or Slackware packages.

10. CentOS

CentOS (abbreviated from Community Enterprise Operating System) is a Linux distribution that attempts to provide a free, enterprise-class, community-supported computing platform which aims to be functionally compatible with its upstream source, Red Hat Enterprise Linux (RHEL).
ceentos
The CentOS Project announced the immediate availability of CentOS 7 for x86_64, including images for docker, and various cloud providers. There are many fundamental changes in this release, compared to previous releases of CentOS.

Conclusion

Different Linux distributions were outlined above. Personally, I am interested in OpenSUSE, Ubuntu and CentOS distributions, the others are optional for me. And you what is your choice?

3/19/15

An Introduction To MySQL Database

About MySQL

MySQL is an open source database management software that helps users store, organize, and retrieve data. It is a very powerful program with a lot of flexibility.

This tutorial will explains how to install MySQL, create a sample database, create a table, insert records into the table, and select records from the table.

Installation

You can install mysql using the following command:
On Ubuntu:
sudo apt-get install mysql-server
On Centos:
sudo yum install mysql-server
Follows the steps below to stop and start MySQL
service mysql start 
Starting MySQL.                                            [  OK  ]
service mysql status
MySQL running (12588) 
service mysql stop
Shutting down MySQL.                                       [  OK  ]

Verifying Installation

You can check the MySQL installed version by performing mysql -V as shown below:
[local-host]# mysql -V
mysql  Ver 14.14 Distrib 5.1.25-rc, for redhat-linux-gnu (i686) using readline 5.1

Access the MySQL shell

Once you have MySQL installed on your droplet, you can access the MySQL shell by typing the following command into terminal:
mysql -u root -p
After entering the root MySQL password into the prompt, you will be able to start building your MySQL database.
mysql -u root -p
Enter password: password
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Creating Databases

After connecting as MySQL root user, you can use this command to create database.
In this example, we will create truetech4 database.
mysql> create database truetech4;
You can check what databases are available by typing this command:
SHOW DATABASES;
Your screen should look something like this:
 mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| truetech4            |  
|                    |
+--------------------+
5 rows in set (0.01 sec)

Creating Tables

Before you create a mysql table, you need to choose the database that you want to use:
USE truetech4;
Database changed
The following example creates a article table.
create table article (
id INT AUTO_INCREMENT PRIMARY KEY,
name varchar(20),
number varchar(10),
page int(10)
writing_date DATE);
The command show tables to view all the tables available in the database.
mysql> SHOW TABLES;
+-------------------+
| Tables_in_truetech4 |
+------------------+
| article         |
+------------------+
1 row in set (0.01 sec)
To view the table description, do the following command
 mysql>DESCRIBE article;
+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| id          | int(11)     | NO   | PRI | NULL    | auto_increment |
| name        | varchar(20) | YES  |     | NULL    |                |
| number      |  int(11)    | YES  |     | NULL    |                |
| page        | char(1)     | YES  |     | NULL    |                |
| writing_date| date        | YES  |     | NULL    |                |
+-------------+-------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

Add Information to Tables

Use the following sample insert commands to insert some records to the article table.
insert into article values(1,'article1','4','a','2012-04-13');
insert into article values(2,'article2','5','b','2012-04-14');
insert into article values(3,'article3','6','C','2012-04-15');
insert into article values(4,'article4','7','d','2012-04-16');
You can take a look at your table using this command
mysql> SELECT * FROM article
+----+------- +----------------+-----------+-------------+
| id | name   | number         | page      |wrinting_date|
+----+------- +----------------+-----------+-------------+
|  1 |article1| 1              | a         | 2012-04-13  |
|  2 |article2| 2              | b         | 2012-04-14  |
|  3 |article3| 3              | c         | 2012-04-15  |
|  4 |article4| 4              | d         | 2012-04-16  |
+----+--------+----------------+-----------+-------------+
4 rows in set (0.00 sec)

Update Information in the Table

You can update a stored information in the table with this command:
UPDATE `article` 
SET 
`number` = '6' 
WHERE `article`.`name` ='article4';

Delete a Row, a Column and a Table

You can  delete rows from the table with the following command:
DELETE from  where [column name]=[field text];
mysql> DELETE from article  where name='article2';
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM article
+----+------- +----------------+-----------+-------------+
| id | name   | number         | page      |wrinting_date|
+----+------- +----------------+-----------+-------------+
| 1 |article1 | 1              | a          | 2012-04-13 |
| 3 |article3 | 3              | c          | 2012-04-15 |
| 4 |article4 | 4              | d          | 2012-04-16 |
+----+--------+----------------+-----------+-------------+
3 rows in set (0.00 sec)
You can also delete a column using this command
ALTER TABLE  [column name];
And type this command if you want to delete all table
ALTER TABLE ;
That’s all for this article.

FIND US ON FACEBOOK

FIND US ON Twitter