Total Pageviews

Friday, 27 June 2014

SAV vs NAS

A storage area network (SAN) is storage connected in a fabric (usually through a switch) so that there can be easy access to storage from many different servers. From the server application and operating system standpoint, there is no visible difference in the access of data for storage in a SAN or storage that is directly connected. A SAN supports block access to data just like directly attached storage.
Network-attached storage (NAS) is really remote file serving. Rather than using the software on your own file system, the file access is redirected using a remote protocol such as CIFS or NFS to another device (which is operating as a server of some type with its own file system) to do the file I/O on your behalf. This enables file sharing and centralization of management for data.
So from a system standpoint, the difference between SAN and NAS is that SAN is for block I/O and NAS is for file I/O. One additional thing to remember when comparing SAN vs. NAS is that NAS does eventually turn the file I/O request into a block access for the storage devices attached to it.

Tomcat: Troubleshoot the Tomcat?

Tomcat: Troubleshoot the Tomcat?
Installing JDK (Java Development Kit)

In order to run Tomcat, you will need to install JDK and set the JAVA_HOME environment variable to identify the location of the JDK environment on your system. I have chosen to use JDK 5.0.

1. You can download JDK 5.0 at http://java.sun.com/j2se/1.5.0/download.jsp.

2. Click on Download JDK 5.0 Update 6 to go to the download page.

3. Click Accept to accept the license agreement.

4. Next choose the Linux self-extracting file. This is the download for the self-extracting binary file rather than the rpm.

5. Download to your preferred download directory. Change to that directory and make it executable by executing the following command:

chmod +x jdk-1_5_0_06-linux-i586.bin

6. Now execute the file:

./jdk-1_5_0_06-linux-i586.bin

7. You should now have a new directory called j2sdk1.5-sun. Now move this directory to the location where it should be run. I chose /usr/lib/.

mv j2sdk1.5-sun /usr/lib

8. Now create a symbolic link called jdk to JAVA_HOME by the following command. This allows you to easily switch back and forth between different jvms should you ever need to

cd /usr/lib

ln -s j2sdk1.5-sun jdk

8. Now we need to set the JAVA_HOME environment variable. Add the following at the end of /etc/profile just after export PATH.

JAVA_HOME="/usr/lib/jdk"

export JAVA_HOME

/etc/profile is executed at startup and when a user logs into the system. In order to update the environment you will need to log out and log back in to the system.

10. Check to make sure JAVA_HOME is defined correctly by executing the command below. This should report the location of the Java SDK which should be /usr/lib/jdk.

echo $JAVA_HOME

11. Now test Java with the following command. You should be returned with /usr/bin/java. If so, you have successfully completed this section.

which java
export JAVA_HOME=/usr/java/jdk1.6.0_15
export PATH=$PATH:$HOME/bin:/bin:/usr/local/bin:/usr/bin:/usr/java/jdk1.6.0_15/bin/


Setting Tomcat

Download the binary version to your preferred download directory from here: http://tomcat.apache.org/download-55.cgi. Choose the tar.gz from the core section for 5.5.15.
Now change to that directory and extract the files using the following command:

cd /mydownloads (be sure to change to your download directory)

tar xvzf apache-tomcat-5.5.15.tar.gz

You should now have a new directory called apache-tomcat-5.5.15. Now move this directory to the location where it should be installed. Again, I chose /usr/lib/. Note that this location will be referred to as CATALINA_HOME in the Tomcat documentation.

mv apache-tomcat-5.5.15 /usr/lib

Next change to the /usr/lib/ directory.

cd /usr/lib

Now create a symbolic link called apache-tomcat to CATALINA_HOME by the following command.

ln -s apache-tomcat-5.5.15 apache-tomcat

[root@linuxguy bin]# echo $CATALINA_HOME
/usr/lib/apache-tomcat
[root@linuxguy bin]# pwd
/usr/lib/apache-tomcat/bin



[root@linuxguy bin]# ./startup.sh
The BASEDIR environment variable is not defined correctly
This environment variable is needed to run this program


How to troubleshoot?


[root@linuxguy bin]# chmod +x *.sh
[root@linuxguy bin]# ./startup.sh
Using CATALINA_BASE: /usr/lib/apache-tomcat
Using CATALINA_HOME: /usr/lib/apache-tomcat
Using CATALINA_TMPDIR: /usr/lib/apache-tomcat/temp
Using JRE_HOME: /usr/java/jdk1.6.0_15
Using CLASSPATH: /usr/lib/apache-tomcat/bin/bootstrap.jar
[root@linuxguy bin]#
[root@linuxguy bin]#

How to differentiate between SATA and PATA drives


Repair Corrupted Grub of RHEL 6

As you are bit in touch with linux and you want to install linux but some times when you install linux and you get some Bootmanager is corrupted or grub > error when you dual boot your linux with any other windows os .So today i will let you know how you can remove this error and boot your both the OSes.


1. Insert the dvd(or 1st cd ) of RHEL6.
2. when your linux cd boot your pc and you have multiple option ,but you need to select a option which says
Recue environment




3. Now select the language and other appropriate options

4. Then select continue to mount your partition in read and write mode.

5. After mounting your partition in read and write mode type the command given below when you have sh shell prompt

chroot /mnt/sysimage

6. Now type this command

grub-install /dev/hda (if you have sata hard disk then use sda in place of hda)

7. Type exit

8. Type exit again

9. System will Reboot !!! enjoy

Linux Network bonding – setup guide

Linux Network bonding – setup guide
Linux network Bonding is creation of a single bonded interface by combining 2 or more Ethernet interfaces. This helps in high availability of your network interface and offers performance improvement. Bonding is same as port trunking or teaming.
Bonding allows you to aggregate multiple ports into a single group, effectively combining the bandwidth into a single connection. Bonding also allows you to create multi-gigabit pipes to transport traffic through the highest traffic areas of your network. For example, you can aggregate three megabits ports into a three-megabits trunk port. That is equivalent with having one interface with three megabytes speed
Steps for bonding in Oracle Enterprise Linux and Redhat Enterprise Linux are as follows..
Step 1.
Create the file ifcfg-bond0 with the IP address, netmask and gateway. Shown below is my test bonding config file.
$ cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0 
IPADDR=192.168.1.12
 
NETMASK=255.255.255.0
 
GATEWAY=192.168.1.1
 
USERCTL=no
 
BOOTPROTO=none
 
ONBOOT=yes
Step 2. 

Modify eth0, eth1 and eth2 configuration as shown below. Comment out, or remove the ip address, netmask, gateway and hardware address from each one of these files, since settings should only come from the ifcfg-bond0 file above. Make sure you add the MASTER and SLAVE configuration in these files.
$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 
BOOTPROTO=none
 
ONBOOT=yes
 
# Settings for Bond
 
MASTER=bond0
 
SLAVE=yes
$ cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1 
BOOTPROTO=none 
 
ONBOOT=yes
 
USERCTL=no
 
# Settings for bonding
 
MASTER=bond0
 
SLAVE=yes
$ cat /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2 
BOOTPROTO=none
 
ONBOOT=yes
 
MASTER=bond0
 
SLAVE=yes
Step 3. 

cat /proc/net/bonding/bond0   

Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 2
Permanent HW addr: 00:0c:29:57:61:8e
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 2
Permanent HW addr: 00:0c:29:57:61:98
Slave queue ID: 0  
Set the parameters for bond0 bonding kernel module. Select the network bonding mode based on you need, documented at http://unixfoo.blogspot.com/2008/02/network-bonding-part-ii-modes-of.html. The modes are
  • mode=0 (Balance Round Robin)
  • mode=1 (Active backup)
  • mode=2 (Balance XOR)
  • mode=3 (Broadcast)
  • mode=4 (802.3ad)
  • mode=5 (Balance TLB)
  • mode=6 (Balance ALB)
Add the following lines to /etc/modprobe.conf
# bonding commands 
alias bond0 bonding
 
options bond0 mode=1 miimon=100
Step 4.
Load the bond driver module from the command prompt.
$ modprobe bonding
Step 5.
Restart the network, or restart the computer.
$ service network restart # Or restart computer
When the machine boots up check the proc settings.
$ cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.0.2 (March 23, 2006)
Bonding Mode: adaptive load balancing 
Primary Slave: None
 
Currently Active Slave: eth2
 
MII Status: up
 
MII Polling Interval (ms): 100
 
Up Delay (ms): 0
 
Down Delay (ms): 0
Slave Interface: eth2 
MII Status: up
 
Link Failure Count: 0
 
Permanent HW addr: 00:13:72:80: 62:f0
Look at ifconfig -a and check that your bond0 interface is active. You are done!. For more details on the different modes of bonding, please refer to unixfoo’s modes of bonding.
To verify whether the failover bonding works..
  • Do an ifdown eth0 and check /proc/net/bonding/bond0 and check the “Current Active slave”.
  • Do a continuous ping to the bond0 ipaddress from a different machine and do a ifdown the active interface. The ping should not break.


Sunday, 22 June 2014

Nagios Installation and Configuration

Step by Step Nagios Installation and Configuration


Nagios is an awesome Open Source monitoring tool, its provides you more comprehensive monitoring environment to always keep an eye on your all machines / networks whether you are in  your data center or just your small labs.

With Nagios, you can monitor your remote hosts and their services remotely on a single window. It shows warnings and indicates if something goes wrong in your servers which eventually helps us to detect some problems before they occur. It helps us to reduce downtime and business losses.

This tutorial explains how to install and configure the Nagios tool on Linux. I am using RHEL 5.8 for installation Nagios.
Before installation of Nagios some prerequisites are required to resolve the dependencies of Nagios.
1.    Install required dependencies:
During portions of the installation you'll need to have root access to your machine.
Make sure you've installed the following packages on your RHEL5.8 installation before continuing installation of Nagios 4.0.1.
  • Apache
  • PHP
  • GCC compiler
  • GD development libraries
You can use yum default package installer to install these packages by running the following commands (as root):
[root@RHEL5 ~]#yum install httpd php
[root@RHEL5 ~]#yum install gcc glibc glibc-common
[root@RHEL5 ~]#yum install gd gd-devel
[root@RHEL5 ~]#yum install make net-snmp

2.    Create Nagios user and Group:

[root@RHEL5 ~]# useradd nagios
[root@RHEL5 ~]# passwd nagios
Changing password for user nagios.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

[root@RHEL5 ~]# groupadd nagcmd
[root@RHEL5 ~]# /usr/sbin/usermod -a -G nagcmd nagios
[root@RHEL5 ~]# /usr/sbin/usermod -a -G nagcmd apache

3.    Download Nagios Core 4.0.1 and Nagios Plugin 1.5
Create a directory for your Nagios installation and all its future downloads.
[root@RHEL5 ~]# mkdir /root/downloads
[root@RHEL5 ~]# cd /root/downloads

Now download latest Nagios Core 4.0.1 and Nagios plugins 1.5 packages with wget command.


4.    Extract Nagios Core and its Plugins:

We need to extract the downloaded packages with tar command.

[root@RHEL5 downloads]# tar -xzvf nagios-4.0.1.tar.gz
[root@RHEL5 downloads]# tar -xzvf nagios-plugins-1.5.tar.gz

When you extract these tarballs with tar command, two new folders will appear in that directory.

[root@RHEL5 downloads]# ls -ltr
total 4060
drwxr-xr-x 15 root root    4096 Oct  2 20:57 nagios-plugins-1.5
drwxrwxr-x 18  root root    4096 Oct 16 05:06 nagios-4.0.1
-rw-r--r--  1   root root 1695367 Oct 16 05:19 nagios-4.0.1.tar.gz
-rw-r--r--  1    root root 2428258 Jan 16  2014 nagios-plugins-1.5.tar.gz

5.    Configure Nagios Core:

i)                  Now, first we will configure Nagios Core and to do so we need to go to Nagios directory and run configure file and if everything goes fine, it will show the output in the end as sample output. Please see below

[root@RHEL5 downloads]# cd nagios-4.0.1
[root@RHEL5 nagios-4.0.1]# ./configure --with-command-group=nagcmd


Sample Output:

*** Configuration summary for nagios 4.0.1 10-15-2013 ***:

 General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagcmd
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
    Install ${includedir}:  /usr/local/nagios/include/nagios
                Lock file:  ${prefix}/var/nagios.lock
   Check result directory:  ${prefix}/var/spool/checkresults
           Init directory:  /etc/rc.d/init.d
  Apache conf.d directory:  /etc/httpd/conf.d
             Mail program:  /bin/mail
                  Host OS:  linux-gnu

 Web Interface Options:
 ------------------------
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  /bin/traceroute

Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.


ii)           Now, after configuring we need to Compile and install all the binaries with make command and make install command will install all the needed libraries in your machine and we can proceed further.

[root@RHEL5 nagios-4.0.1]# make all
[root@RHEL5 nagios-4.0.1]# make install

Sample Output:

*** Main program, CGIs and HTML files installed ***

You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

  make install-init
     - This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs sample config files in /usr/local/nagios/etc

make[1]: Leaving directory `/root/downloads/nagios-4.0.1'

iii)          Following command will install the init scripts for Nagios.

[root@RHEL5 nagios-4.0.1]# make install-init
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios

*** Init script installed ***

iv)          To make nagios work from command line we need to install command-mode.

[root@RHEL5 nagios-4.0.1]# make install-commandmode
/usr/bin/install -c -m 775 -o nagios -g nagcmd -d /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw

*** External command directory configured ***

v)           Next, install sample nagios files, please run following command.

[root@RHEL5 nagios-4.0.1]# make install-config

6.    Customizing Nagios Configuration:

Open the “contacts.cfg” file with your choice of editor and set the email addressassociated with the nagiosadmin contact definition to receiving email alerts.

[root@RHEL5 ~]# vi /usr/local/nagios/etc/objects/contacts.cfg

##############################################################################
 CONTACTS
##############################################################################

# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.

define contact{
        contact_name          nagiosadmin             ; Short name of user
        use          generic-contact    ; Inherit default values from generic-contact template (defined above)
        alias        Nagios Admin            ; Full name of user

        email  jitendrakumaryogi@gmail.com    ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }

7.    Install and configure Web Interface for Nagios:

We are done with all configuration in the backend, now we will configure Web Interface for Nagios with following command. The below command will Configure Web interface for Nagios and a web admin user will be created “nagiosadmin”.

[root@RHEL5 nagios-4.0.1]# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf

*** Nagios/Apache conf file installed ***

In this step, we will be creating a password for “nagiosadmin”. After executing this command, please provide a password twice and keep it remember because this password will be used when you login in the Nagios Web interface.

[root@RHEL5 nagios-4.0.1]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache to make the new settings take effect.

[root@RHEL5 nagios-4.0.1]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

8.    Compile and Install Nagios Plugin:

We have downloaded nagios plugins in /root/downloads, Go there and configure and install it as directed below.

[root@RHEL5 nagios-4.0.1]# cd /root/downloads/
[root@RHEL5 downloads]# cd nagios-plugins-1.5
[root@RHEL5 nagios-plugins-1.5]#./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@RHEL5 nagios-plugins-1.5]# make
[root@RHEL5 nagios-plugins-1.5]# make install

9.    Verify Nagios configuration file:

Now we are all done with Nagios configuration and its time to verify it and to do so please insert following command. If everything goes smooth it will show up similar to below output.

[root@RHEL5 nagios-plugins-1.5]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

10.  Add Nagios Services to System Startup:

To make Nagios work across reboots, we need to add nagios and https with chkconfig command.

[root@RHEL5 nagios-plugins-1.5]# chkconfig --add nagios
[root@RHEL5 nagios-plugins-1.5]# chkconfig --level 35 nagios on
[root@RHEL5 nagios-plugins-1.5]#  chkconfig --add httpd
[root@RHEL5 nagios-plugins-1.5]# chkconfig --level 35 httpd on

Restart Nagios to make the new settings take effect.

[root@RHEL5 nagios-plugins-1.5]# service nagios start
nagios is stopped
Starting nagios:                                           [  OK  ]

11.  Modify SELinux Settings:
RedHat ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs. See if SELinux is in Enforcing mode.
            [root@RHEL5 nagios-4.0.1]# getenforce
Put SELinux into Permissive mode.
            [root@RHEL5 nagios-4.0.1]# setenforce 0

To make this change permanent, you'll have to modify the settings in/etc/selinux/config and reboot.
Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode:

[root@RHEL5 nagios-4.0.1]# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
[root@RHEL5 nagios-4.0.1]# chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

12. Login to Nagios Web Interface:


Your nagios is ready to work, please open it in your browser with “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” and provide the username “nagiosadmin” and password.

Nagios Login