Sunday, January 25, 2009

ISA 2006 and migration troubles

Our ISA 2004 server got screwed up and from my previous experience I'd found that setting up a new one and importing the settings is easier than troubleshooting one. So while my colleague worked on troubleshooting the existing one, I put up a new server with ISA 2006 ( a FORCED upgrade ;) )
and tried importing the old settings to the new server.

I'd exported the configuration of the ISA 2004 server to an xml file some time back so that came in handy today. But while importing, it prompted for a password. I don't remember ever providing a password for the exported xml. I tried my usual ones but it was all in vain. I tried deleting the password line in the xml file.It didn't work. Finally after going through some forums etc. I figured out that the best way was to export the config of the new ISA 2006 to a new file, open the new and old xml files in an xml editor and identify the Array and Enterprise sections. Copy over the two sections from the old config to the newly exported file. Save it and import the configurations from the new xml file. You should have all the settings and rules of the old server working.

Wednesday, January 21, 2009

MySQL backup script



#!/bin/bash
# A simple shell script to backup all MySQL Server Database
# Each dump will be line as follows:
# Directory: /var/lib/mysql/backup/mm-dd-yyyy
# File: mysql-DBNAME.04-25-2008.gz
# -------------------------------------------------------------------------
NOW=$(date +"%m-%d-%Y") # mm-dd-yyyy format
FILE="db-full-$NOW.tar.gz"
BAK="/var/lib/mysql/backups/"

### Server Setup ###
#* MySQL login user name *#
MUSER="user"

#* MySQL login PASSWORD name *#
MPASS="pass"

#* MySQL binaries *#
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"

# get all application related databases
DBS="$($MYSQL -u $MUSER -p$MPASS -Bse 'show databases' | grep -v information_schema)"

# create backups securely
umask 006

# start to dump database one by one
for db in $DBS
do
FILE=$BAK/mysql-$db.$NOW.gz
# gzip compression for each backup file
$MYSQLDUMP -u $MUSER -p$MPASS $db | $GZIP -9 > $FILE
done

Websphere startup script for linux

Startup script for Websphere Application server on linux. Its got an added check for Oracle connectivity before the service is brought up.



#!/bin/bash
# Websphered # Startup script for IBM WebSphere Application Server
#
# chkconfig: - 99 15
# description: IBM's J2EE application server
# processname: websphered
# pidfile: /var/run/websphered.pid

# Source function library.
. /etc/rc.d/init.d/functions

websphered=/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin
args=server1
prog="WebSphere Application Server"
proc=/opt/IBM/WebSphere/AppServer/java/bin/java
RETVAL=0
username=user
password=password


# verify installation
if [ ! -x $websphered ]; then
echo "$prog is not installed"
exit 0
fi

# source function library
. /etc/rc.d/init.d/functions


case "$1" in
start)

# Continous loop to check Oracle connectivity. Websphere should come up only if Oracle is up.
for (( ; ; ))
do

# Check for Oracle connectivity

su - oracle -c '/opt/Oracle/product/10.2.0/client_1/bin/tnsping database_name ' | grep OK;
PRC_EXT_STAT=$?;

# If Oracle is pingable, then startup WAS and break out of loop

if [ $PRC_EXT_STAT = "0" ]; then
echo -n "Starting Websphere Application Server: "
$websphered/startServer.sh $args
RETVAL=$?
if [ $RETVAL = 0 ]; then
touch /var/lock/subsys/websphered
echo_success
else
echo_failure
fi
#Break out of loop
break;
echo
fi
# Wait 30 seconds before checking again
echo " Waiting for Oracle connectivity: "
sleep 30

done

;;
stop)
echo -n "Shutting down websphered: "
$websphered/stopServer.sh $args -username $username -password $password
RETVAL=$?
if [ $RETVAL = 0 ]; then
rm -f /var/lock/subsys/websphered
echo_success
else
echo_failure
fi
echo
;;
restart)
$0 stop
$0 start
;;
status)
status $proc
;;
*)
echo "Usage: websphered {start|stop|restart|status}"
exit 1

esac

exit 0