Monday, May 24, 2010

How to Update PHP

For most, using RPM as a package manager, If you upgrade/install php you will see a lot of dependecy errors and all, which is quite annoying. So plese Follow the below steps to make it easy.

I. If PHP is installed in your system then remove it. Put this in a script or from shell.
# for i in `rpm -qa|grep -i php`; do rpm -e $i --nodeps; done

II. rpm -ivh php52-common-5.2.13-1.el5.x86_64.rpm php52-cli-5.2.13-1.el5.x86_64.rpm php52-5.2.13-1.el5.x86_64.rpm

Now if you do "php -v" you can see the version of PHP.

Hope it will be helpful to all of you.

Wednesday, May 19, 2010

How to prepare a custom Kickstart CD

Creating a custom Kickstart CD for Red Hat

This article explains how to create a custom boot CD for Red Hat Enterprise Linux containing a customized Kickstart file. When completed, the boot CD will contain all of the instructions necessary to create a custom Red Hat Linux system with little or no intervention.

Step By Step

1. Place Disk 1 of the Red Hat Enterprise Linux CD set into the CDROM drive.

2. Navigate to the /images directory on the CD.

3. Locate the boot.iso file and copy it to your hard drive.

4. Mount the boot.iso file using the following command:

mount -o loop -t iso9660 boot.iso /mnt/iso

If the /mnt/iso directory does not already exist you will need to create it. You also may need to be the root user to mount the boot.iso file.

5. Change to the /mnt/iso directory and copy the contents to another location (we are using /home/jeff in this example):

cd /mnt/iso
cp -R isolinux /home/jeff

6. Copy the Kickstart ks.cfg file to the new directory (this presumes ks.cfg is already located in /home/jeff):

cd /home/jeff
cp ks.cfg ./isolinux

7. Change to the /isolinux directory:

cd isolinux

8. Run the following command to create a new .iso file:

mkisofs -r -T -J -V "RedHatKSBoot" -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -v -o /home/jeff/redhat_ks_boot.iso .

This will create a file named redhat_ks_boot.iso located in /home/jeff. It will be the same as the original boot.iso file we started with, with the exception of the ks.cfg file that was added.

9. Burn the redhat_ks_boot.iso file to a CD.
Initiating Kickstart

Boot the box on which you wish to install this customized version of Red Hat Enterprise Linux. At the boot: prompt, type the following:

linux ks=cdrom:/ks.cfg

Red Hat should then begin its boot process. You will then be prompted with the following message:

The Red Hat Enterprise Linux CD was not found in any of your CDROM drives.
Please insert the Red Hat Enterprise Linux CD and press OK to retry.

Replace the custom boot CD with Disk 1 of the Red Hat Enterprise Linux disk set and press OK. The Kickstart process will now take over and install Red Hat as per the instructions contained in ks.cfg.

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