Housekeeping Alert Log

The following command can be used to delete trace files greater than 30 days.

/bin/find /oracle/product/admin -name \"*.trc\" -mtime +30 -exec rm -f {} \;

Also, here is a scipt that I use to rename my alert logs daily. Currently, I keep 1 year worth of alerts logs – which is controlled by the variable LOG_KEEP_DAYS in the script. The script is run from cron everynight at 23:59 using the following cron entry:

###Refresh the alert_logs every day…so that we only have one day
###of alert info to research in case there is a problem…don’t need
###to wad through days or months of alert info in just one log file.
59 23 * * * /oracle/product/local/scripts/save_alert_log.sh > /dev/null 2>&1

 

#!/usr/bin/ksh

############################################################################
## Program : save_alert_log.sh #
## #
## Purpose : The alert logs on many Oracle databases can grow to a very #
## large size over time. This can often impede the maintenace#
## of the system – because the DBA will need to sometimes scan#
## through many days or months of data when researching an #
## issue. This script tries to avoid that by ensuring that #
## the log file can be “refreshed" on a daily basis, meaning #
## that only the current day’s data will be kept in the log, #
## while the previous day’s data will be saved to another file#
## in a backup area. #
## #
## This script should be run from Oracle’s crontab at midnight#
## every night, so that the database will always have a new #
## alert log file each day. An example crontab entry could be#
## 0 00 * * * /oracle/product/local/scripts/save_alert.sh 2>&1#
## #
## Date : 19 May 2006. #
## Author : Basil S. Mullings #
############################################################################
## Modified: #
## #
## #
# Modification History: #
# DATE WHO DESC #
# ——– —– —————————————————-#
# 05/29/06 Basil Add an extra variable LOG_KEEP_DAYS to hold the #
# number of days that the log files should be kept on #
## the server before being deleted. #
## #
## #
############################################################################

##Setup some needed variables.
BKUP=bkup ##The backup directory to store the logs…
ORATAB="/etc/oratab"
LOG_KEEP_DAYS=365 ##Keep this many days of log files on the server.
TMPFILE=/var/tmp/OracleAlertLog ##Just a temp scratch work area.
SQLUSER="/ as sysdba"
GEN_ORA_ERROR="ORA\-[0-9][0-9]*"
PATH="$HOME:$HOME/bin:/usr/contrib/bin:/usr/local/bin:/usr/bin:/bin:/etc:."
export PATH

## Now, parse the oratab file for all databases on the system.
## Then use the ORACLE_SID that is found in the oratab file
## to log onto that database, and retrieve the directory where
## the alter log file is stored (.ie. retrieve the path to the
## bdump directory.
##
#for sidEntry in `cat $ORATAB | grep -v “^#"`
for sidEntry in `cat $ORATAB | awk -F: ‘{print $1}’ | grep -v “^#"`
do
## Get date and time
CURR_DATE=`date ‘+%a_%m%d%H%M’` ##Example Fri_05191256 for Friday May 19th @1256 PM.

#ORACLE_SID=`echo $sidEntry | cut -f 1 -d :`
ORACLE_SID=$sidEntry
echo “Oracle Sid is $ORACLE_SID"

export ORACLE_SID
## Set the Oracle environment for this SID.
ORAENV_ASK=NO
. /usr/local/bin/oraenv
rm -f $TMPFILE > /dev/null 2>&1

##Now, let’s log onto the DB, and try to
##retrieve the bdump directory path.
sqlplus -s /nolog << EOF > $TMPFILE
connect $SQLUSER
set heading off;
set echo off;
set feedback off;

select ‘BACKGROUND_DUMP_DEST=’ ||value
from v\$parameter
where name=’background_dump_dest’;
exit;
EOF

##Ok, we had a problem talking to the database.
if [ `grep -c $GEN_ORA_ERROR $TMPFILE` -ne 0 ]
then
echo “ERROR: Unable to find the path to the alert log for DB $ORACLE_SID"
rm -f $TMPFILE > /dev/null 2>&1

else ##Ok, we can log into the DB, now let’s go find our bdump directory.

bdump=`grep BACKGROUND_DUMP_DEST $TMPFILE | awk -F “=" ‘{print $2}’`
#echo “BDUMP is $bdump"
bkupDir=$bdump/$BKUP

##Make sure our backup directory exists.
if [ ! -d $bkupDir ]
then
mkdir $bkupDir > /dev/null 2>&1
fi

##Now, move the alert log.
#echo “now moving $bdump/alert_${ORACLE_SID}.log to $bkupDir/alert_${ORACLE_SID}.$CURR_DATE"
mv $bdump/alert_${ORACLE_SID}.log $bkupDir/alert_${ORACLE_SID}.$CURR_DATE

#Procedure to shrink the log to 365 days
##Keep only the last 365 days worth of logs…delete all logs older than 365 days.
#echo “Now shrinking the logs in dir $bkupDir …"
find $bkupDir -name “*.*" -mtime +${LOG_KEEP_DAYS} -exec rm -f {} \;
fi

done

https://community.oracle.com/thread/1062919

Purge Archived Logs in Standby Database

#!/bin/ksh

. /scripts/dba/bin/SetOracleEnv

export script=`basename $0`

export tmpf=/tmp/”${script}_${vdate}.tmp”

export logtokeep=5

### Get Max sequence # applied from Primary database ###

applied_sequence=`sqlplus -silent /nolog <<EOSQL

connect / as sysdba

whenever sqlerror exit sql.sqlcode

set pagesize 0 feedback off verify off heading off echo off

select max(sequence#) from v\\$archived_log where applied = ‘YES’ and REGISTRAR=’RFS’;

exit;

EOSQL`

### Calculate the archive log # to delete ###

arch_to_del=$(($applied_sequence-$logtokeep))

#echo “applied_sequence: ” $applied_sequence

#echo “arch_to_del: “$arch_to_del

if [ -z “$arch_to_del” ]; then

echo “No rows returned from database” >> ${tmpf}

exit 0

fi

#delete old logs – current applied -5

#

rman << EORMAN >> ${tmpf}

connect target ;

#delete noprompt archivelog all completed before ‘SYSDATE-1′ ;

delete noprompt archivelog until sequence = $arch_to_del;

exit

EORMAN

echo

find /tmp/$script*.tmp -mtime +30 | xargs /bin/rm -f >> ${tmpf}

du -hs /u04/oradata/TS2PRD/flash_recovery_area/TS2STB/* >> ${tmpf}

exit

https://anargodjaev.wordpress.com/2013/10/15/script-to-delete-arch-logs-from-dataguard-when-archivelog-backups-are-taken-from-primary-database/

=====

cd
. ./setdb
applied_sequence=`sqlplus -silent /nolog <<EOSQL
connect / as sysdba
whenever sqlerror exit sql.sqlcode
set pagesize 0 feedback off verify off heading off echo off
select max(sequence#)-35 from v\\$archived_log where applied = ‘YES’ and REGISTRAR=’RFS’;
exit;
EOSQL`
export applied_sequence

tmpf=/tmp/”delete_archive_logs.tmp”
export tmpf
echo “” > $tmpf

rman << EORMAN >> ${tmpf}
connect target ;
delete noprompt archivelog until sequence = $applied_sequence;
change archivelog all crosscheck;
delete noprompt expired archivelog all;
exit
EORMAN

msub=”List of archive logs deleted from STANDBY SERVER are @”`date`
export msub

tolist=”NallapaReddy.Arveti@abc.com,somireddy.tetali@abc.com,nageswararao.macherla@abc.com”
export tolist

mailx -r noreply@abc.com -s “$msub” ${tolist} < /tmp/delete_archive_logs.tmp

=================

https://somireddy.wordpress.com/2012/07/24/how-to-purge-applied-archive-logs-from-standby-server/

PRE="set pagesize 0 \n set feedback off \n"; SS="$ORACLE_HOME/bin/sqlplus -L -S / as sysdba"
ROLE=$(echo -e “$PRE select database_role from v\$database;" | $SS)
[[ “$ROLE" != “PHYSICAL STANDBY" ]] && { echo “ERROR: database not a physical standby"; exit 1; }
THREADS=$(echo -e “$PRE select distinct thread# from v\$archived_log;" | $SS)
for THREAD in $THREADS; do
MAX_APPLIED=$(echo -e “$PRE select max(sequence#) from v\$archived_log where applied=’YES’ and thread#=$THREAD;" | $SS)
echo “delete noprompt archivelog until sequence $MAX_APPLIED thread $THREAD;"|rman target /
done

http://www.oaktable.net/content/delete-archived-logs-standby

 

 

Application Performance

http://apmblog.dynatrace.com/2014/06/10/understanding-application-performance-on-the-network-part-i-a-foundation-for-network-triage/

http://apmblog.dynatrace.com/2014/06/19/understanding-application-performance-on-the-network-bandwidth-and-congestion/

http://apmblog.dynatrace.com/2014/06/26/understanding-application-performance-on-the-network-tcp-slow-start/

http://apmblog.dynatrace.com/2014/07/03/understanding-application-performance-on-the-network-packet-loss/

http://apmblog.dynatrace.com/2014/07/10/understanding-application-performance-on-the-network-processing-delays/

http://apmblog.dynatrace.com/2014/07/24/understanding-application-performance-on-the-network-the-nagle-algorithm/

http://apmblog.dynatrace.com/2014/08/12/understanding-application-performance-network-part-tcp-window-size/