Thursday, April 22, 2010

How to Install EMC Powerpath on Linux

Download the Powerpath software from EMC powerlink website. If you’ve purchased EMC support, you should have access to powerlink.

This is tested on OEL5 and Clarion

# rpm -ivh EMCpower.LINUX-5.x.x.x.x.rhel5.i386.rpm --test
Preparing... ########################################### [100%]

# rpm -ivh EMCpower.LINUX-5.x.x.x.x.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:EMCpower.LINUX ########################################### [100%]
All trademarks used herein are the property of their respective owners.
NOTE:License registration is not required to manage the CLARiiON AX series array.

2. Register EMC Powerpath

Before you can use the EMC powerpath software, you should register it using the EMC Powerpath License key received when you purchased the software from EMC.

Use emcpreg tool to install EMC Powerpath license key as shown below.

# emcpreg -install

=========== EMC PowerPath Registration ===========
Do you have a new registration key or keys to enter?[n] y
Enter the registration keys(s) for your product(s),
one per line, pressing Enter after each key.
After typing all keys, press Enter again.

Key (Enter if done): **emc-powerpath-license-key**
1 key(s) successfully added.
Key successfully installed.

Key (Enter if done):
Key is invalid, ignored.
Try again or press Enter if done.
1 key(s) successfully registered.

3. Verify EMC Powerpath Registration

Use EMC powermt command to check the registration as shown below.

# powermt check_registration

Key **emc-powerpath-license-key**
Product: PowerPath
Capabilities: All

4. Verify Multiple Paths

Once you’ve installed EMC powerpath, execute powermt display dev=all as shown below to verify whether multiple paths as displayed accordingly.

# powermt display dev=all
Pseudo name=emcpowera
CLARiiON ID=00000000000 [db-server]
Logical device ID=12121212121212 [LUN 1]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP A, current=SP A
==============================================================================
---------------- Host --------------- - Stor - -- I/O Path - -- Stats ---
### HW Path I/O Paths Interf. Mode State Q-IOs Errors
==============================================================================
1 QLogic Fibre Channel 2300 sdb SP A4 active alive 0 0
1 QLogic Fibre Channel 2300 sdd SP B4 active alive 0 0
2 QLogic Fibre Channel 2300 sdf SP A5 active alive 0 0
2 QLogic Fibre Channel 2300 sdh SP B5 active alive 0 0

Automated Installation Script for Oracle

Scenario : In my cuurent project i had to work a lot on Oracle installlation and configuration stuff, so before installing oracle a lot of parameter needed to be changed and all which is a time consuming work, as a lazy admin i wrote this script..If you want to make some changes please do and share too :)

#!/bin/bash
#..................................................................................#
####### Oracle Installation Script ########
###This is the script which will tune the OS and install the required packages ###
####### Created By Pradyumna [Copyleft ;)] #######
####### This Script should run as root User #######
#..................................................................................#

DATE=$(date +"%Y%m%d")
echo "Installing Required packages,Make sure YUM is configured neither install manually "
yum install binutils elfutils elfutils-libelf gcc gcc-c++ glibc glibc-common glibc-devel compat-libstdc++-33 cpp make compat-db sysstat libaio libaio-devel unixODBC unixODBC-devel
echo "Package Installation is done"

#This lines needed to be added to the limits.conf file

echo "Changing limits.conf file"
cp /etc/security/limits.conf /etc/security/limits.conf_$DATE
echo " The backup of the original file is taken"
cat >> /etc/security/limits.conf <oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
echo "limits.conf file changed successfully"


#Add lines to profile to give maximum limit for Oracle user
echo "Changing /etc/profile file"
echo "Taking the backup of profile"
cp /etc/profile /etc/profile.bak_$DATE
echo " The backup of the file is done"
cat >> /etc/profile <if [ \$USER = "oracle" ]; then
if [ \$SHELL = "bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF
echo "/etc/profile file changed successfully"

#The below lines needed to be added to the /etc/pam.d/login file
echo "Taking the Backup Of login file "
cp /etc/pam.d/login /etc/pam.d/login.bak_$DATE
echo "Backup is done ....................."
echo "Changing /etc/pam.d/login file.."
cat >> /etc/pam.d/login <session required /lib/security/pam_limits.so
session required pam_limits.so
EOF
echo "/etc/pam.d/login file changed successfuly"

#Add some kernel parameters to /etc/sysctl.conf file
echo "Changing kernel parameters"
cp /etc/sysctl.conf /etc/sysctl.conf.backup_$DATE
echo " Sysctl backup is done.........."
cat >> /etc/sysctl.conf <fs.file-max = 6553600
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144
EOF
echo "Kernel parameters changed successfully"
#Save all new kernel parameters
/sbin/sysctl -p


#Create new groups and oracle user and add this user to the respective groups

echo "Creating new groups and .oracle user "
groupadd oinstall
groupadd dba
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
else
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -g oinstall -G dba -d /home/oracle -s /bin/bash -c .Oracle Software Owner. oracle
useradd -m -p $pass $username
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
fi
else
echo "Only root may add a user to the system"
exit 2
fi

#groupadd oinstall
#groupadd dba
#useradd -m -g oinstall -G dba -d /home/oracle -s /bin/bash -c .Oracle Software Owner. oracle
#passwd oracle
echo "Groups and user created successfully"

######### Creating Oracle Directory And Setting Permissions ##########
mkdir -p /u02/app/oracle
chown -R oracle:oinstall /u02/app
chmod -R 775 /u02/app
echo "Directories and the permission are set"

#Adding Environment Variables
cp /home/oracle/.bashrc /home/oracle/.bashrc_backup_$DATE
echo " The File Backup is done "
cat >> /home/oracle/.bashrc <TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=localhost.localdomain; export ORACLE_HOSTNAME
ORACLE_BASE=/u02/app/oracle; export ORACLE_BASE
ORACLE_HOME=/u02/app/oracle/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=PHNXTEST; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
DISPLAY=localhost:0.0; export DISPLAY
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
export LD_LIBRARY_PATH=/u02/app/oracle/product/11.2.0/dbhome_1/lib32
EOF

#Unzip setup of Oracle
#Place the ZIP file in the /home directory of Oracle
su - oracle
echo "Unzipping setup of Oracle 10g Release 2.. ."
echo "Keep the ZIP files/installers in the /home/oracle directory"
unzip linux.x64_11gR2_database_1of2.zip
echo "Setup file successfully unzipped"

#Enter to installation directory and run the installation .

echo "Installation begins"
cd /home/oracle/11gR1_db/database
chmod 755 runInstaller
sh runInstaller

Friday, April 16, 2010

How to add a LUN withour rebooting in kernel 2.6

I have used this in Linux kernel 2.6. In 2.4 the steps are different, if you need that then mail me To add new SAN disk or newly created LUN in

Red Hat Enterprise Linux run following commands:

1. Rescan your qlogic HBA's:

#echo "scsi-qlascan" > /proc/scsi/driver-name/adapter-id

The driver-name can be qla21XX/qla22XX etc

2. Perform scsi mid layer rescan :


Once that has been done, you can force the SCSI layer to do its own scan and build the device table entry for the new device:

# echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi

The scsi mid layer will perfume re-scan on "0 1 2 3" .Replace these numbers depending upon your Linux server "Host Channel Id Lun". The scanning has to be done inthe above mentioned order.

Check into "dmesg | less"

echo "scsi-qlascan" > /proc/scsi/qlaXX00/1

echo "scsi-qlascan" > /proc/scsi/qlaXX00/2

echo "scsi add-single-device 1 0 0 6" >/proc/scsi/scsi

Startup/Shutdown Script for Oracle

In my current project i wrote a startup/shutdown script for Oracle. Thought to share with you guys, may be helpful for you all. So if you use it in your env then make sure to modify the ORACLE environment variable as per your system.
This script is self-explanatory, Still if you not able to understand then give me a shout :). Well Yes this is the script for Oracle 11.2.0.1.0, so i have used dbshut and dbstart, which automatially start and stop listner. However i also find some kinda of bug in the dbstart and dbstop script, i mean a little tweaking made this script.

#!/bin/bash
#
# chkconfig: 345 99 10
#......................................................
# description: Oracle auto start-stop script
#
# Location: /etc/init.d
#.......................................................
ORACLE_OWNER=oracle; export ORACLE_OWNER

ORACLE_BASE=/u02/app/oracle; export ORACLE_BASE

ORACLE_BIN_DIR=$ORACLE_BASE/product/11.2.0/dbhome_1/bin/; export ORACLE_BIN_DIR

ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
#/u02/app/oracle/product/11.2.0/dbhome_1

# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
RETVAL=0
prog="oracle"
start()
{
echo -n $"STARTING UP $prog: "
if [ ! -f $ORACLE_BIN_DIR/dbstart ]
then
echo "Oracle not started (no dbstart script)"
else
# Start RDBMS
su - $ORACLE_OWNER -c "$ORACLE_BIN_DIR/dbstart $ORACLE_HOME"
fi
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/oracle
return $RETVAL
}
stop()
{
echo -n $"SHUTTING DOWN $prog: "
if [ ! -f $ORACLE_BIN_DIR/dbshut ]
then
echo "Oracle cannot be stopped [No dbshut Script Found)"
else
su - $ORACLE_OWNER -c "$ORACLE_BIN_DIR/lsnrctl status"
stat=$?
echo $stat
su - $ORACLE_OWNER -c "$ORACLE_BIN_DIR/dbshut $ORACLE_HOME"
fi
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/oracle
return $RETVAL
}

restart()
{
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
status)
status $prog
RETVAL=$?
;;

*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL

How To Install/Remove/List Packages By YUM

Task: List all installed packages
List all installed packages, enter:
# yum list installed
Find out if httpd package installed or not, enter:
# yum list installed httpd
Task: Check for and update specified packages
# yum update {package-name}
To check for and update httpd package, enter:
# yum update httpd
Task: Search for packages by name
Search httpd and all matching perl packages, enter:
# yum list {package-name}
# yum list {regex}
# yum list httpd
# yum list perl*

Task: Install the specified packages [ RPM(s) ]
Install package called httpd:
# yum install {package-name}
# yum install httpd
Task: Remove / Uninstall the specified packages [ RPM(s)]
Remove package called httpd, enter:
# yum remove httpd
Task: Display the list of available packages
# yum list all
Task: Display list of group software
Type the following command:
# yum grouplist

Task: Install all the default packages by group
Install all 'Development Tools' group packages, enter:
# yum groupinstall "Development Tools"

Task: Update all the default packages by group
Update all 'Development Tools' group packages, enter:

# yum groupupdate "Development Tools"

Task: Remove all packages in a group
Remove all 'Development Tools' group packages, enter:

# yum groupremove "Development Tools"
Task: Install particular architecture package
If you are using 64 bit RHEL version it is possible to install 32 packages:

# yum install {package-name}.{architecture}

Task: Display what package provides the file
You can easily find out what RPM package provides the file. For example find out what provides the /etc/passwd file:
# yum whatprovides /etc/passwd
You can use same command to list packages that satisfy dependencies:
# yum whatprovides {dependency-1} {dependency-2}

Extending Filesystem By LVM


How to Increase a File system
scenario : suppose you want to increase /home file system to 20GB

As you can see, we have used 20% up all the available space on the filesystem and the size is 4.9 GB now we want to increase it to 15GB.If this filesystem had been created on a disk partition, the only way forward would be either to delete some data or to repartition the disk, but LVM can extend the logical volume and the filesystem. We have to start with the logical volume:

# lvdisplay /dev/mapper/VolGroup01-LogVol04|grep -i Size
LV Size 5.00 GB

#lvextend -L10G dev/mapper/VolGroup01-LogVol04

Extending logical volume testlv to 10G

Logical volume testlv successfully resized

Now to increase the file system without reboot

#resize2fs /dev/mapper/VolGroup01-LogVol04

Linux Router How to

How to setup Linux as a router [ Throttler Machine ]

There are a few ways to set up a Linux machine as route. Here is a relatively straight forward and common method. This method requires that the system use iptables for Network Address Translation (NAT).

This step by step small how to will help you to setup Linux router only in 2 minutes.

Configuration steps

  • First enable packet forwarding
  • Next setup Network Address Translation using IPTABLES MASQUERADE targets
  • Save the changes
  • Verify everything is working

A) We are using OEL Linux distro

B) eth0 is internet interface (connected to router for example) and eth1 connected to our internal LAN (connected to your HUB/Switch for example).

My Linux eth1 --> Intranet [ 192.168.0.1 ]

box eth2 --> Lan [ADC] [ 10.23.X.X ]

Step I : Turn on ip forwarding in kernel

I) Open linux kernel configuration file (you must be a root user or use su - command to become a root user):

# vi /etc/sysctl.conf

II) Add/modify following line:


net.ipv4.ip_forward = 1

Step II: Restart network


# /etc/init.d/network restart

Step III: Setup IP forwarding and Masquerading (to act as router), you need to use NAT option of iptables as follows (add following rules to your iptables shell script if you want to make it permanent that is /etc/init.d/iptables in the start section :

# iptables --table nat --append POSTROUTING --out-interface eth2 -j MASQUERADE
# iptables --append FORWARD --in-interface eth1 -j ACCEPT

Step IV: You are done! Test it with ping