Par manque de place dans un filesystem, on peut être amené à déplacer des archive logs.
Si on les déplace avec l’OS (mv) alors Oracle ne saura plus où ils sont. Il faudra utiliser RMAN pour supprimer les anciens (crosscheck archivelog all ; delete expired archivelog all; catalog start with ‘…’ ; )
Mais il y a plus rapide: BACKUP AS COPY fait une copie des fichiers et avec DELETE INPUT on supprime la source. Ce qui revient à les déplacer…
Exemple:
Je génère 3 archivelogs.
RMAN> sql "alter system archive log current"; sql statement: alter system archive log current RMAN> sql "alter system archive log current"; sql statement: alter system archive log current RMAN> sql "alter system archive log current"; sql statement: alter system archive log current
Les voici:
RMAN> list archivelog all; List of Archived Log Copies for database with db_unique_name ORCL ===================================================================== Key Thrd Seq S Low Time ------- ---- ------- - --------- 8528 1 8512 A 14-JUN-13 Name: /app/oracle/fast_recovery_area/ORCL/archivelog/2013_06_14/o1_mf_1_8512_8voshs5y_.arc 8529 1 8513 A 14-JUN-13 Name: /app/oracle/fast_recovery_area/ORCL/archivelog/2013_06_14/o1_mf_1_8513_8vosht61_.arc 8530 1 8514 A 14-JUN-13 Name: /app/oracle/fast_recovery_area/ORCL/archivelog/2013_06_14/o1_mf_1_8514_8voshy3l_.arc
Je les déplace vers /tmp:
RMAN> backup as copy archivelog all format '/tmp/%U' delete input; Starting backup at 14-JUN-13 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=8512 RECID=8528 STAMP=818070265 output file name=/tmp/arch_D-ORCL_id-1634007513_S-8512_T-1_A-747580379_qmoc5gou RECID=8532 STAMP=818070302 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: deleting archived log(s) archived log file name=/app/oracle/fast_recovery_area/ORCL/archivelog/2013_06_14/o1_mf_1_8512_8voshs5y_.arc RECID=8528 STAMP=818070265 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=8513 RECID=8529 STAMP=818070266 output file name=/tmp/arch_D-ORCL_id-1634007513_S-8513_T-1_A-747580379_qnoc5gov RECID=8533 STAMP=818070303 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: deleting archived log(s) archived log file name=/app/oracle/fast_recovery_area/ORCL/archivelog/2013_06_14/o1_mf_1_8513_8vosht61_.arc RECID=8529 STAMP=818070266 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=8514 RECID=8530 STAMP=818070270 output file name=/tmp/arch_D-ORCL_id-1634007513_S-8514_T-1_A-747580379_qooc5gp1 RECID=8534 STAMP=818070305 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: deleting archived log(s) archived log file name=/app/oracle/fast_recovery_area/ORCL/archivelog/2013_06_14/o1_mf_1_8514_8voshy3l_.arc RECID=8530 STAMP=818070270 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=8515 RECID=8531 STAMP=818070302 output file name=/tmp/arch_D-ORCL_id-1634007513_S-8515_T-1_A-747580379_qpoc5gp2 RECID=8535 STAMP=818070306 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: deleting archived log(s) archived log file name=/app/oracle/fast_recovery_area/ORCL/archivelog/2013_06_14/o1_mf_1_8515_8vosjyql_.arc RECID=8531 STAMP=818070302 Finished backup at 14-JUN-13 Starting Control File and SPFILE Autobackup at 14-JUN-13 piece handle=/app/oracle/fast_recovery_area/ORCL/autobackup/2013_06_14/o1_mf_s_818070307_8vosk3hj_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 14-JUN-13
Et voici les archivelogs:
RMAN> list archivelog all; List of Archived Log Copies for database with db_unique_name ORCL ===================================================================== Key Thrd Seq S Low Time ------- ---- ------- - --------- 8532 1 8512 A 14-JUN-13 Name: /tmp/arch_D-ORCL_id-1634007513_S-8512_T-1_A-747580379_qmoc5gou 8533 1 8513 A 14-JUN-13 Name: /tmp/arch_D-ORCL_id-1634007513_S-8513_T-1_A-747580379_qnoc5gov 8534 1 8514 A 14-JUN-13 Name: /tmp/arch_D-ORCL_id-1634007513_S-8514_T-1_A-747580379_qooc5gp1 8535 1 8515 A 14-JUN-13 Name: /tmp/arch_D-ORCL_id-1634007513_S-8515_T-1_A-747580379_qpoc5gp2
Les noms ont changé (j’ai utilisé %U pour les générer), mais l’important c’est que Oracle sache où ils sont.
La syntaxe RMAN est assez particulière, et leur output aussi. Mais il est intéressant de bien les comprendre. Les exemples complets sont ici: demo.