O RMAN possui um parâmetro persistente responsável pela regra de remoção dos archived redo logs, que por padrão está definido como NONE (ou seja, você consegue deletar um archived redo log sem realizar um backup dele, o que não é sugerido):
[oracle@oel8 ~]$ rman target /
Recovery Manager: Release 18.0.0.0.0 - Production on Sat Mar 27 05:13:17 2021
Version 18.13.0.0.0
Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.
connected to target database: RMANDB (DBID=3825250984)
RMAN> SHOW ARCHIVELOG DELETION POLICY;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name RMANDB are:
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
Deste modo, toda vez que realizar as operações “BACKUP … DELETE INPUT”, “DELETE ARCHIVELOG” e “DELETE OBSOLETE”, os archives serão removidos sem ainda possuírem um backup realizado. Fazendo uma demonstração desse comportamento:
RMAN> LIST BACKUP OF ARCHIVELOG ALL;
specification does not match any backup in the repository
RMAN> LIST COPY OF ARCHIVELOG ALL;
specification does not match any archived log in the repository
RMAN> RMAN> ALTER SYSTEM SWITCH LOGFILE;
Statement processed
RMAN> DELETE ARCHIVELOG ALL;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=60 device type=DISK
List of Archived Log Copies for database with db_unique_name RMANDB
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
71 1 64 A 2021-03-26:04:53:29
Name: /oracle/archives/1_64_1036964654.dbf
Do you really want to delete the above objects (enter YES or NO)? Y
deleted archived log
archived log file name=/oracle/archives/1_64_1036964654.dbf RECID=71 STAMP=1068268611
Deleted 1 objects
Alterando o parâmetro para que permita o delete caso o arquivo tenha sofrido backup ao menos uma vez:
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
new RMAN configuration parameters are successfully stored
O erro \”RMAN-08138\” é reportado justamente pelo comportamento esperado:
RMAN> ALTER SYSTEM SWITCH LOGFILE;
Statement processed
RMAN> DELETE ARCHIVELOG ALL;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=60 device type=DISK
RMAN-08138: warning: archived log not deleted - must create more backups
archived log file name=/oracle/archives/1_65_1036964654.dbf thread=1 sequence=65
Só após realizar o backup, que o RMAN consegue deletar os archivelogs:
RMAN> BACKUP ARCHIVELOG ALL;
Starting backup at 2021-03-27:05:26:16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=65 RECID=72 STAMP=1068269072
input archived log thread=1 sequence=66 RECID=73 STAMP=1068269176
channel ORA_DISK_1: starting piece 1 at 2021-03-27:05:26:16
channel ORA_DISK_1: finished piece 1 at 2021-03-27:05:26:17
piece handle=/oracle/fra/RMANDB/backupset/2021_03_27/o1_mf_annnn_TAG20210327T052616_j5xv190o_.bkp tag=TAG20210327T052616 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2021-03-27:05:26:17
Starting Control File and SPFILE Autobackup at 2021-03-27:05:26:18
piece handle=/oracle/fra/RMANDB/autobackup/2021_03_27/o1_mf_s_1068269178_j5xv1bpv_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2021-03-27:05:26:21
RMAN> DELETE ARCHIVELOG ALL;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=60 device type=DISK
List of Archived Log Copies for database with db_unique_name RMANDB
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
72 1 65 A 2021-03-27:05:16:50
Name: /oracle/archives/1_65_1036964654.dbf
73 1 66 A 2021-03-27:05:24:31
Name: /oracle/archives/1_66_1036964654.dbf
Do you really want to delete the above objects (enter YES or NO)? Y
deleted archived log
archived log file name=/oracle/archives/1_65_1036964654.dbf RECID=72 STAMP=1068269072
deleted archived log
archived log file name=/oracle/archives/1_66_1036964654.dbf RECID=73 STAMP=1068269176
Deleted 2 objects
Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laboratório pessoal para fins de aprendizado.