TFA(Trace File Analyzer) on OHAS

References:
Making Applications Highly Available Using 11gR2 Grid Infrastructure 
(Doc ID 1105489.1)

On this post i will show how to add the TFACTL as a resource on CRS, on my case 
is a standalone installation, so will be on 
OHAS (Oracle High Availability Services).

1.) Changes as ROOT:

cd $TFA_HOME
chmod -R o+r *
chmod -R o+x *

Include Oracle on /etc/sudoers to execute TFACTL as root, on my case oracle has
right to execute anything as root, check with your sysadmin.

oracle  ALL=(ALL) NOPASSWD: ALL

On /etc/sudoers set the option below:
Defaults    !requiretty

2.) Script:
To automate the process, we need create a script with CRS application standard. 
You can find on (Doc ID 1105489.1).
This script should be created as Grid owner.
-----------------------------------------------------------------------------
#!/bin/sh
# Author: Carlos Magno
########################################
logfile=/tmp/tfacrs.out
lockfile=/oracle/tfa/lnx01/tfa_home/tfa.lock
CMD=/oracle/tfa/bin/tfactl
PIDosw=`ps -ef | grep TFAMain | grep -v grep | awk '{print $2}'`
vPar=$1
echo "Option:" $vPar >> $logfile
case $1 in
  'start')
    echo `/bin/date` " start " `/usr/bin/id` >> $logfile
    if [ -e $lockfile ]; then
       echo "TFA already started" >> $logfile
    else
      sudo $CMD $vPar
    fi
    RET=$?
    ;;
  'stop')
    echo `/bin/date` " stop " `/usr/bin/id` >> $logfile

    if [ -e $lockfile ]; then
           sudo $CMD $vPar
    else
       echo "TFA not running" >> $logfile
    fi
    RET=$?
    ;;
  'clean')
    echo `/bin/date` " clean " `/usr/bin/id` >> $logfile
    sudo kill -9 $PIDosw
    RET=0
    ;;
  'check')
    echo `/bin/date` " check " `/usr/bin/id` >> $logfile
    if [ -e $lockfile ]; then
          echo "CHECK - TFA is running" >> $logfile
      RET=0
    else
      echo "CHECK - TFA is not running" >> $logfile
      RET=1
    fi
    tail -1  $logfile
    ;;
  *)
    echo `/bin/date` " unknown " `/usr/bin/id` >> $logfile
    RET=0
    ;;
esac
if [ $RET -eq 0 ]; then
  exit 0
else
  exit 1
fi
-----------------------------------------------------------------------------
After created the script, you need execute:
chmod +x <script name>

execute some tests with the script. On my case my script is:
/home/oracle/dba/scripts/oracle_exec_tfa.sh
./oracle_exec_tfa.sh (start|stop|clean|check)

To check: /tmp/tfacrs.out
3.) Adding on CRS
crsctl add resource TFACRS.ora -type ora.local_resource.type -attr 
"AUTO_START=always,ACTION_SCRIPT=/home/oracle/dba/scripts/oracle_exec_tfa.sh"

4.) Start Resource
crsctl start resource TFACRS.ora
crsctl stat res -t

CRSCTL_TFACTL

Log on CRS to check:
/<ORACLE BASE>/diag/crs/<HOSTNAME>/crs/trace/ohasd_scriptagent_oracle.trc
Advertisements

One thought on “TFA(Trace File Analyzer) on OHAS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s