Thursday, April 5, 2012

One night restoring Oracle Database 10g from archive log with RMAN

The following is an RMAN (Oracle Recovery Manager) script used this night to restore the archive logs from a RMAN backup.


The catalog is located on a different machine. The backup is on tapes like the one below.


DLT Tape


We needed to restore only the archives from sequence number 409237 to 409287 to recover a corrupted datafile.


We specified a different location for the restored archived logs rather than the original one with "set archivelog destination to 'location'" command.


Have fun! (actually IF you have to restore archive logs you are NOT going to have fun hehe).


[oracle@host-a ~]$ rman
Recovery Manager: Release 10.2.0.4.0 - Production on Thu Apr 5 01:17:57 2012


Copyright (c) 1982, 2007, Oracle.  All rights reserved.


RMAN> connect target /connected to target database: DBSID (DBID=2456460023)
RMAN> connect catalog user/password@catalog-hostconnected to recovery catalog database
RMAN> run {
allocate channel 'dev_0' type 'sbt_tape' parms 'ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=DBSID,OB2BARLIST=DBSID_Archive_A)';
set archivelog destination to '/home/oracle/ora-archive/DBSID/tmp';
restore archivelog from logseq=409237 until logseq=409287 thread=1;
release channel 'dev_0';
}


Wednesday, April 4, 2012

Sample and simple linux RedHat 5 kickstart file

The title says it all ... It's a minimal kickstart file.

# Kickstart config file by morenji 2010
# Profile Label : RHEL55-x86-64
# Date Created  : 2010-11-24 15:33:25.0

install
text
network --bootproto dhcp
url --url ftp://10.155.194.171/RedHat/RHEL55/x86_64/dvd
lang en_US
keyboard it
zerombr
clearpart --all
part / --fstype "ext3" --size=8192
part /boot --fstype "ext3" --size=100 --asprimary
part /home --fstype "ext3" --size=100 --grow
part /var --fstype "ext3" --size=8192
part swap --size=4096
part swap --size=4096
bootloader --location mbr
timezone Europe/Rome
auth --enablemd5 --enableshadow
rootpw --iscrypted CYPTEDPASSWORRRDDDDDDD
selinux --disabled
reboot
firewall --disabled
skipx
key --skip

%packages 

@ Base


Jboss monitoring

The following bash script is an attempt to monitor multiple JBoss instances at once. It aims to check whether JDBC connections (i.e. datasource) are active and functional and whether an expected list of EJB and WARs have been deployed or not on a given instance. It consists of a bash shell script and a configuration .ini where the parameters are stored.

WARNING: this is a starting point. If you fancy to use it in a production environment you have to do some work on it. Moreover since the JMX query vary among different jboss versions, if you are going to monitor different jboss versions you should move the JMX queries in the .ini file.

Have fun!

BASH Script

#!/bin/bash
#
# Moreno Daltin 2011
#
#

set -e

INITFILE='jstatus.ini'
LOGFILE='jstatus.log'

echo Jstatus v.0.1 morenji 2011

if [ x$1 == x ]
then
        echo Usage $0 \<application\>
        exit 1
fi

# ini parser by /var/log/ajdiaz
# http://ajdiaz.wordpress.com/2008/02/09/bash-ini-parser/

cfg_parser ()
{
    ini="$(<$1)"                # read the file
    ini="${ini//[/\[}"          # escape [
    ini="${ini//]/\]}"          # escape ]
    IFS=$'\n' && ini=( ${ini} ) # convert to line-array
    ini=( ${ini[*]//;*/} )      # remove comments with ;
    ini=( ${ini[*]/\    =/=} )  # remove tabs before =
    ini=( ${ini[*]/=\   /=} )   # remove tabs be =
    ini=( ${ini[*]/\ =\ /=} )   # remove anything with a space around =
    ini=( ${ini[*]/#\\[/\}$'\n'cfg.section.} ) # set section prefix
    ini=( ${ini[*]/%\\]/ \(} )    # convert text2function (1)
    ini=( ${ini[*]/=/=\( } )    # convert item to array
    ini=( ${ini[*]/%/ \)} )     # close array parenthesis
    ini=( ${ini[*]/%\\ \)/ \\} ) # the multiline trick
    ini=( ${ini[*]/%\( \)/\(\) \{} ) # convert text2function (2)
    ini=( ${ini[*]/%\} \)/\}} ) # remove extra parenthesis
    ini[0]="" # remove first element
    ini[${#ini[*]} + 1]='}'    # add the last brace
    eval "$(echo "${ini[*]}")" # eval the result
}

# Parse del file di configurazione
cfg_parser 'jstatus.ini'

echo Processing application $1

cfg.section.$1

STATUS=0

# Controllo delle webapp

for i in ${WAR[@]}
do
        echo -n webapp --\> $i --\>
        MBEAN=`$TWIDDLE -u $JMX_USER -p $JMX_PASS --server=$JMX_URL query jboss.web.deployment:* 2> $LOGFILE|grep $i` || { STATUS=1}
        if [ "x$MBEAN" == "x" ]
        then
                echo deploy not found
                exit 1
        fi
        STATESTRING=`$TWIDDLE -u $JMX_USER -p $JMX_PASS --server=$JMX_URL get --noprefix $MBEAN StateString 2> $LOGFILE` || { STATUS=1}
        if [ "x$STATESTRING" !"xStarted" ]
        then
                echo Failed
                STATUS=1
        else
                echo $STATESTRING
        fi
done

for i in ${EJB[@]}
do
echo -n ejb --\> $i --\>
        MBEAN=`$TWIDDLE -q -u $JMX_USER -p $JMX_PASS --server=$JMX_URL query jboss.j2ee:service=EjbModule,module=$i 2> $LOGFILE` || { STATUS=1}
        if [ "x$MBEAN" == "x" ]
        then
                echo deploy not found
                exit 1
        fi
        STATESTRING=`$TWIDDLE -q -u $JMX_USER -p $JMX_PASS --server=$JMX_URL get --noprefix $MBEAN StateString 2> $LOGFILE` || { STATUS=1}
        if [ "x$STATESTRING" !"xStarted" ]
        then
                echo Failed
                STATUS=1
        else
                echo $STATESTRING
        fi
done

for i in ${DATASOURCE[@]}
do
echo -n datasource --\> $i --\>
        MBEAN=`$TWIDDLE -q -u $JMX_USER -p $JMX_PASS --server=$JMX_URL query jboss.jca:service=DataSourceBinding,name=$i 2> $LOGFILE` || { STATUS=1}
        if [ "x$MBEAN" == "x" ]
        then
                echo datasource not found
                exit 1
        fi
        STATESTRING=`$TWIDDLE -q -u $JMX_USER -p $JMX_PASS --server=$JMX_URL get --noprefix $MBEAN StateString 2> $LOGFILE` || { STATUS=1}
        if [ "x$STATESTRING" !"xStarted" ]
        then
                echo Failed
                STATUS=1
        else
                echo $STATESTRING
        fi
done

exit $STATUS


Example INI FILE


[app1]
TWIDDLE=/home/jboss/EnterprisePlatform-5.1.0/jboss-eap-5.1/jboss-as/bin/twiddle.sh
JMX_USER=admin
JMX_PASS=pass
JMX_URL="jnp://app1.domain:1199"
WAR="morenjidb" "jmx-console"
[app2]
TWIDDLE=/home/jboss/EnterprisePlatform-5.1.0/jboss-eap-5.1/jboss-as/bin/twiddle.sh
JMX_USER=admin
JMX_PASS=password
JMX_URL="jnp://app2.domain:1099"
WAR="jmx-console.war" "app.war"
EJB="ejb.jar" "ejb2.jar" "antanius.jar"
DATASOURCE="ds.1" "DefaultDS" "ds2"


Morgana monitoring Jboss