on 10-09-2007 8:09 AM
One question: has someone an idea how to configure the standby database to delete the recovered offline redo logs on the standby side?
Data-Guard Manager has the control over the instances. so i cannot use brarchive to recover the standby side.
Now i have no idea how i can delete the recovered offline redo.logs?
Has someone an idea?
Thanks in advance
Greetings Michael
Michael,
You could script it to first read the database and then delete the logs that have been applied or in our case, we have a cron job that runs daily and deletes archive log files on standby server that are more then a day old.
find.. mtime +1 exec rm
As we have regular notifications setup to inform us of the logshipping status.
Cheers,
Nisch
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the script i used then, of course i can give no support on it. I do also not have the time to translate the german commentarish ))
It was tested under HP-UX 11.23.
#!/usr/bin/ksh
###############################################################
#
standbylog_clean.sh #
------------------- #
#
Loescht Logfiles die auf der Standby Datenbank applied sind #
#
Aufruf: ./standbylog_clean.sh (als oracle user) #
Version: 0.1, 19.07.2005, mho #
#
###############################################################
Nebeneffekte:
- einige aeltere Versionen von tail koennen nur etwa 500
Zeilen ausgeben, dadurch kann das Logfile kuerzer werden
als eigentlich gewollt
- Falls die Log Namen nicht das Format *_<Sequenznummer>.dbf
haben werden die Zeilen mit den SED Kommandos nicht
funktionieren! Das Script sollte trotzdem funktionieren,
ist allenfalls bei hohen Sequenznummern langsamer
Systemabhaengige Variablen - bitte anpassen
logfile="/oracle/SID/scripts_basis/standbylog_clean.log"
standbylogdir="/oracle/SID/saparch/standby/"
orauser=orac11
maxloglines=1000
externe Binaries - eventuell anpassen
ECHO="/usr/bin/echo"
LS="/usr/bin/ls"
WC="/usr/bin/wc"
WHOAMI="/usr/bin/whoami"
SED="/usr/bin/sed"
SORT="/usr/bin/sort"
HEAD="/usr/bin/head"
RM="/usr/bin/rm"
MV="/usr/bin/mv"
TAIL="/usr/bin/tail"
CAT="/usr/bin/cat"
DATE="/usr/bin/date"
GREP="/usr/bin/grep"
Datum merken
dat=`$DATE '+%d.%m.%Y %H:%M'`
Logfile trimmen
if [ -f $logfile ] && [ `$CAT $logfile | $WC -l` -gt $maxloglines ]; then
newloglines=$(( $maxloglines - 10 ))
$TAIL -$newloglines $logfile > $.tmp $MV $.tmp $logfile
fi
sind wir oracle user?
if [ `$WHOAMI` != "$orauser" ]; then
$ECHO "$dat Bitte als $orauser starten - exit" >> $logfile
exit
fi
haben wir ueberhaupt irgendwelche Logs?
if [ `$LS -1 $standbylogdir/*.dbf | $WC -l` -eq 0 ]; then
$ECHO "$dat Keine Logfiles vorhanden - exit" >> $logfile
exit
fi
ist die DB im MOUNT status (ansonsten ist sie entweder unten,
oder sogar offen, in beiden Faellen machen wir nix)?
sql='SELECT STATUS FROM V$INSTANCE;'
status=`sqlplus -s "/ as sysdba" <<EOF
set feed off
set heading off
set pagesize 0
set linesize 1000
$sql
exit
EOF`
if [ "$status" != "MOUNTED" ]; then
$ECHO "$dat Die Datenbank ist nicht gemounted - exit" >> $logfile
exit
fi
schauen welches das tiefste Log ist
lognum=`$LS -1 /oracle/C11/saparch/standby/.dbf | $SED -e 's/._//' -e 's/\.dbf//' | $SORT -n | $HEAD -1`
if [ `$ECHO $lognum | $GREP '^[0-9][0-9]*$' | $WC -l` -eq 0 ]; then
da ist was faul mit der Nummer
lognum=1
fi
v$archived_logs abfragen
sql='SELECT NAME FROM V$ARCHIVED_LOG WHERE SEQUENCE# >= '"$lognum AND APPLIED = 'YES';"
files=`sqlplus -s "/ as sysdba" <<EOF
set feed off
set heading off
set pagesize 0
set linesize 1000
$sql
exit
EOF`
Files loeschen
for file in $files; do
if [ -f $file ]; then
loglastnum=`$ECHO $file | $SED -e 's/.*_//' -e 's/\.dbf//'`
$RM $file
fi
done
if [ "$loglastnum" = "" ]; then
$ECHO "$dat Keine Logs zum loeschen, warte bis diese APPLIED sind" >> $logfile
else
$ECHO "$dat Habe die Logs $lognum - $loglastnum geloescht" >> $logfile
fi
Hi Michael
I had the same issue when testing data guard with 9i. I wrote a little shell script
It basically does this on the standby side:
- check if there is one or more archive redo logs
- check whether the log is already applied:
[code]SELECT NAME FROM V$ARCHIVED_LOG WHERE SEQUENCE# >= $lognum AND APPLIED = 'YES';[/code]
- if yes, then delete
Regards
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.