1. 如果没有备份机制,想要实现备库归档自动删除,就需要使用快速恢复区(FRA)
检查当前备库归档的存放位置:
SQL> show parameter log_archive_dest_1
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
log_archive_dest_1 string location=/archdir valid_for=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby
2. 更改FRA配置
ALTER SYSTEM SET db_recovery_file_dest_size=60g SCOPE=BOTH;
ALTER SYSTEM SET db_recovery_file_dest=/archdir SCOPE=BOTH;
ALTER SYSTEM SET log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(ALL_LOGFILES, ALL_ROLES) DB_UNIQUE_NAME=standby' SCOPE=BOTH;
3. 重启备库
ALTER DATABASE RECOVER managed standby database cancel;
shutdown immediate
startup mount
ALTER DATABASE RECOVER managed standby database disconnect from session;
此时alert里显示新的archivelog存放到FRA里
Media Recovery Log /archdir/STANDBY/archivelog/2017_07_13/o1_mf_2_265_dpgfvl3o_.arc
4. 配置rman的归档删除策略
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
当FRA空间达到80%使用率时,就会自动删除已经应用的archivelog:
Deleted Oracle managed file /archdir/STANDBY/archivelog/2017_07_18/o1_mf_2_412_dpvh6d5d_.arc