Tuesday, June 06, 2006

[Oracle]Solve problem, when we have more audit files

we configured audit_sys_operations equal true or audit_trail equal OS.
Our oracle db, that have more audit files.
So we think move old file to some folders.

my scripts

auditparameter.sql file =>
set heading off;
set pages 0
set pagesize 0;
set echo off;
set feedback off;
set termout on;
set linesize 250;
set trimspool on;
SELECT VALUE FROM V$PARAMETER WHERE NAME='audit_file_dest';
exit;




rtadump.sh file =>

#!/bin/sh
#Write by me http://surachart.blogspot.com
#Version 0.1

# Set two parameters ORACLE_HOME, DPATH
ORACLE_HOME=/oracle/product/10.2.0/db
DPATH=/oracle/admin/CONCURRT/adump/

ORACLE_SID=$1
export ORACLE_HOME
export ORACLE_SID

if [ -z $1 ]
then

echo "Please fill up SID"
echo "example: rtadump.sh TEST"
echo " -test test script"
exit
fi

DEST=`${ORACLE_HOME}/bin/sqlplus / as sysdba @${HOME}/sbin/auditparameter.sql | /bin/grep \/ | /bin/awk '{print $1}'`

P1=`echo ${DPATH} | /bin/sed 's/\///g'`
P2=`echo ${DEST} | /bin/sed 's/\///g'`

if [ ! -z $2 ]
then
if [ $2 = '-test' ]
then
echo "P1:"$P1
echo "P2:"$P2
if [ ${P1} = ${P2} ]
then
echo "Script verify done."
else
echo "Please check parameter on this script."
fi
else
echo "Please fill up SID -test"
echo "example: rtadump.sh -test"
fi
exit

fi




if [ ${P1} = ${P2} ]
then

if [ -d ${DPATH} ]
then
YDATE=`date +'%Y%m%d' -d yesterday`
NPATH=${DPATH}${YDATE}/

if [ -d ${NPATH} ]
then
/bin/mv ${NPATH} ${NPATH}.old
fi

/bin/mkdir ${NPATH}

/usr/bin/find ${DPATH} -type f -name '*aud' -mtime +0 -exec /bin/mv {} ${NPATH} \;

fi
fi



When we created these scripts, test by

./rtadump.sh CONCURRT1 -test
and use by
./rtadump.sh CONCURRT1

No comments: