Recently deleted the archive log of DG,
[oracle@.local logs]crontab -l* 8 * * * sh /home/oracle/dbscripts/del_arc.sh
This script calls the three scripts that generate the delete verification respectively.
cat del_arc.sh#! /bin/bashsource /home/oracle/.bash_profilesh /home/oracle/dbscripts/build_del_archivelog.sh >> /home/oracle/dbscripts/del_arch`date +%F_%H`.shsleep 5sh /home/oracle/dbscripts/del_arch`date +%F_%H`.sh >> /home/oracle/dbscripts/logs/del_arch`date +%F_%H`.logsleep 5sh /home/oracle/dbscripts/crosscheck_archivelog.sh >> /home/oracle/dbscripts/logs/cross_check`date +%F_%H`.log
First look at the generated
cat build_del_archivelog.sh sqlplus -s shark/235619<<EOFset heading offset linesize 1000set echo offset feedback offset timing offset termout onset trimout offset trimspool onset newpage noneselect 'rm -f '||name from v\$archived_log where applied='YES' and deleted='NO' and completion_time < trunc(sysdate);EOF
It is mainly used to generate archive logs for physically deleting applications and obtain them from V $ archived_log. Note that the NAME in the ASM disk management does not contain the path.
In addition, the distance between each line generated is too large. Please advise.
Generated Delete script
]head del_arch2014-05-07_08.sh rm -f /arch_backup/1_24144_831167377.log rm -f /arch_backup/2_22765_831167377.log
That is, Y's line spacing is too large.
]cat crosscheck_archivelog.sh #! /bin/bashsource /home/oracle/.bash_profileexec >> /home/oracle/dbscripts/logs/del_arch`date +%F_%H`.log$ORACLE_HOME/bin/rman target / <<EOFcrosscheck archivelog all;delete noprompt expired archivelog all;#delete noprompt archivelog until time 'sysdate-1';exit;EOF
This is the final script for validation! We can see from the annotations that we used to delete archived logs.
This check script is mainly used to clear the archive information. If the information is stored in the control file, DG cannot be deleted.