1. Data Guard master database archive deletion policy:
When we set:
RMAN> configure archivelog deletion policy to applied on standby;
In Maximum Availability and Maximum Performance, when RMAN backs up the archive file and adds delete input, the archive will be deleted.
RMAN> configure archivelog deletion policy to none;
The archive deletion policy is canceled.
2. Data Guard backup database archive deletion policy
The archive deletion policy for the standby database is upgraded on the basis of the standalone version, and the log function is added. The archive file for the master database of the two RAC nodes can be deleted from the standby database, it can be executed as a scheduled task or separately in interactive form.
Because the standby database generally does not execute the rman backup plan, you need scripts to delete these archive log files.
[Oracle @ www.bkjia.com backup_scripts] $ vim delstarch. sh
Export ORACLE_THREAD = $1
Export ORACLE_HOME =/u01/app/oracle/product/11.2.0/dbhome_1
Export ORACLE_SID = bdspoc
Export SHELL_DIR =/u01/app/oracle/backup_scripts
Export DATE = $ (date + % Y-% m-% d \ % H: % M: % S)
If [! $ ORACLE_THREAD]; then
Read-p "Enter deleted thread [1 | 2]:"
DB_THREAD = $ REPLY
Else
DB_THREAD = $ ORACLE_THREAD
Fi
If [$ DB_THREAD = 1]; then
Del_seq = 'ls/arch | grep ^ 1 | cut-f2-d _ | sort-n | head-1'
Echo $ del_seq "is the minimum archlog sequence"
$ ORACLE_HOME/bin/sqlplus-s "sys/***** as sysdba" <eof> $ SHELL_DIR/max_sn.log
Set head off;
Set feedback;
Select max (sequence #) from v \ $ log_history where THREAD # = 1;
Exit;
Eof
Max_sn = 'cat/u01/app/oracle/backup_scripts/max_sn.log | awk '{print $1}' | grep ^ [0-9]'
# Keep the last 20 archives, and delete all others
Max_sn = 'expr $ max_sn-20'
Echo $ max_sn "is the maximum archlog sequence"
While [$ del_seq-lt $ max_sn]
Do
DATE = $ (date + % Y % m % d _ % H % M % S)
Rm/arch/1 _ "$ del_seq" _ 816281825.arc
DATE = $ (date + % Y-% m-% d \ % H: % M: % S)
# Because log_archive_format is of the % t _ % s _ % r. arc type, % r is the resetlog id
Echo "$ DATE"/arch/1 _ "$ del_seq" _ 816281825.arc >>$ SHELL_DIR/delarch. log
Del_seq = 'expr $ del_seq + 1'
Echo "$ DATE" 1 _ "$ del_seq" _ 816281825.arc
Done
Elif [$ DB_THREAD = 2]; then
Del_seq = 'ls/arch | grep ^ 2 | cut-f2-d _ | sort-n | head-1'
Echo $ del_seq "is the minimum archlog sequence"
$ ORACLE_HOME/bin/sqlplus-s "sys/***** as sysdba" <eof> $ SHELL_DIR/max_sn.log
Set head off;
Set feedback;
Select max (sequence #) from v \ $ log_history where upper (THREAD #) = 2;
Exit;
Eof
Max_sn = 'cat/u01/app/oracle/backup_scripts/max_sn.log | awk '{print $1}' | grep ^ [0-9]'
Max_sn = 'expr $ max_sn-20'
Echo $ max_sn "is the maximum archlog sequence"
While [$ del_seq-lt $ max_sn]
Do
Rm/arch/2 _ "$ del_seq" _ 816281825.arc
DATE = $ (date + % Y-% m-% d \ % H: % M: % S)
Echo "$ DATE"/arch/2 _ "$ del_seq" _ 816281825.arc >>$ SHELL_DIR/delarch. log
Echo "$ DATE" 2 _ "$ del_seq" _ 816281825.arc has been deleted
Del_seq = 'expr $ del_seq + 1'
Done
Else
Echo "$ DATE" There has a fault db_thread value! >>$ SHELL_DIR/delarch. log
Fi
Interactive execution can be performed, for example:
[Oracle @ www.bkjia.com backup_scripts] $ sh delstarch. sh
Enter deleted thread [1 | 2]: 1 -- select which node to delete the log files archived from.
You can also make a scheduled task to execute this script.
[Root @ www.bkjia.com ~] # Crontab-l
0 1 *** su-oracle-c/u01/app/oracle/backup_scripts/delstarch. sh 1
0 2 *** su-oracle-c/u01/app/oracle/backup_scripts/delstarch. sh 2
Every day, 1 node is executed to archive log files, and 2 nodes are executed to archive log files.
Recommended reading:
Oracle 11g rac modify archive Mode
Oracle RMAN clears archived logs
Oracle 11g Flashback Data Archive (flash back Data archiving)