Oracle Data guard synchronizes data through archive files. The archive files of the master database can be deleted during RMAN backup, but the archive files of the slave database cannot be deleted automatically. You need to write scripts to delete them regularly.
If you delete an archive file directly, you may find that the archive file has not been urgently applied. Therefore, the safest way is to delete the archive file and make a judgment. Then, delete the file.
The shell script for deleting the slave database is as follows:
[Oracle @ qs-xezf-db2 Scripts] $ cat del_st_archive.sh
#! /Usr/bin/KSh
# Created by tianlesoftware
#2010/12/24
Export ORACLE_HOME =/u01/APP/Oracle/product/10.2.0/db_1
Export oracle_sid = xxxx
Export shell_dir =/u02/scripts
Del_seq = 'ls/u02/archivelog/| head-1 | cut-F2-D _'
Echo $ del_seq
$ ORACLE_HOME/bin/sqlplus-s "User/pwd @ sid_pd as sysdba" <EOF>/u02/scripts/max_sn.log
Set head off;
Set feedback;
Select max (sequence #) from V/$ log_history;
Exit;
EOF
Max_sn = 'cat/u02/scripts/max_sn.log | awk '{print $1}' | grep ^ [0-9]'
Max_sn = 'expr $ max_sn-30'
-- I keep the last 30 archive files here. I will decide the specific situation.
Echo $ max_sn
While [$ del_seq-lt $ max_sn]
Do
Rm/u02/archivelog/1 _ "$ del_seq" _ 737806218.arc
-- Here I define the format of the archive file. The key is matching the log Sequence No according to the format of the archive file.
Del_seq = 'expr $ del_seq + 1'
Echo $ del_seq
Done
-- Modify the red part of the script based on your own situation.
[Oracle @ qs-xezf-db2 Scripts] $ ls
Del_st_archive.sh del_st_arch.log max_sn.log
-- Max_sn.log is the tmp file that stores the largest seq. Used for comparison
Add to crontab for scheduled execution:
[Oracle @ qs-xezf-db2 Scripts] $ crontab-l
00 6 ***/u02/scripts/del_st_archive.sh>/u02/scripts/del_st_arch.log 2> & 1
Linux Crontab scheduled task commands
Http://blog.csdn.net/tianlesoftware/archive/2010/02/21/5315039.aspx
------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
Online Resources: http://tianlesoftware.download.csdn.net
Video: http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
Dba1 group: 62697716 (full); dba2 group: 62697977 (full)
Dba3 group: 62697850 super DBA group: 63306533;
Chat group: 40132017
-- Add the group to describe the relationship between Oracle tablespace and data files in the remarks section. Otherwise, the application is rejected.