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 @ bkjia www.bkjia.com] $ 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 @ bkjia www.bkjia.com] $ 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 @ bkjia www.bkjia.com] $ crontab-l
00 6 ***/u02/scripts/del_st_archive.sh>/u02/scripts/del_st_arch.log 2> & 1
Linux Crontab scheduled task commands