• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to delete archives from only 1 archive destination when 2 or more are in use

by admin

If you want to delete the archives of 1 LOG_ARCHIVE_DEST using rman command and want to keep the archive logs from other LOG_ARCHIVE_DEST_[n] for some other purpose, then use DELETE LIKE-clause in RMAN.

This way you can maintain the archives in one location and keep the same copy of the archives in another location. Consider the below example:

1. You have 2 archive destinations to keep the archive logs.

/u01/app/oracle/arch/test2
/u01/app/oracle/test/arch2
SQL> show parameter log_archive_dest

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string location=/u01/app/oracle/arch/test2
log_archive_dest_5 string location=/u01/app/oracle/test/arch

2. All the archives are on the above two locations.

$ ls -ltr /u01/app/oracle/test/arch/*
total 248
-rw-r----- 1 oracle oinstall 212480 Mar 14 13:26 1_32_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_33_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_35_776337487.dbf
-rw-r----- 1 oracle oinstall 3584 Mar 14 13:26 1_34_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_36_776337487.dbf
$ ls -lrt /u01/app/oracle/arch/test2/*
-rw-r----- 1 oracle oinstall 212480 Mar 14 13:26 1_32_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_33_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_35_776337487.dbf
-rw-r----- 1 oracle oinstall 3584 Mar 14 13:26 1_34_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_36_776337487.dbf

3. Now backup the archived redologs from ‘/u01/app/oracle/arch/test2’ and delete them afterwards, but do not delete the archives from the other location : ‘/u01/app/oracle/test/arch’. Example command:

RMAN> backup archivelog like '/u01/app/oracle/arch/test2%' delete input;"

Output:

Recovery Manager: Release 11.2.0.2.0 - Production on Wed Mar 14 13:30:30 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (DBID=859136735)

RMAN> backup archivelog like '/u01/app/oracle/arch/test2%' delete input;

Starting backup at 14-MAR-2012 13:31:50
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
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=23 RECID=32 STAMP=777885413
input archived log thread=1 sequence=24 RECID=33 STAMP=777885414
input archived log thread=1 sequence=25 RECID=35 STAMP=777885416
input archived log thread=1 sequence=26 RECID=34 STAMP=777885416
input archived log thread=1 sequence=27 RECID=36 STAMP=777907018
channel ORA_DISK_1: starting piece 1 at 14-MAR-2012 13:31:54

channel ORA_DISK_1: finished piece 1 at 14-MAR-2012 13:32:59
piece handle=/u01/app/oracle/fast_recovery_area/TEST2/backupset/2012_03_14/o1_mf_annnn_TAG20120314T133152_7p0n3ldh_.bkp tag=TAG20120314T133152 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/arch/test2/1_32_776337487.dbf RECID=41 STAMP=777907585
archived log file name=/u01/app/oracle/arch/test2/1_33_776337487.dbf RECID=43 STAMP=777907587
archived log file name=/u01/app/oracle/arch/test2/1_34_776337487.dbf RECID=45 STAMP=777907588
archived log file name=/u01/app/oracle/arch/test2/1_35_776337487.dbf RECID=47 STAMP=777907588
archived log file name=/u01/app/oracle/arch/test2/1_36_776337487.dbf RECID=49 STAMP=777907589
Finished backup at 14-MAR-2012 13:33:00

Recovery Manager complete.

4. RMAN deleted the files in “/u01/app/oracle/arch/test2” and not in “/u01/app/oracle/test/arch”. You can verify the result as shown below.

$ ls -lrt /u01/app/oracle/arch/test2/*
total 0
$ ls -lrt /u01/app/oracle/test/arch/*
total 248
-rw-r----- 1 oracle oinstall 212480 Mar 14 13:26 1_32_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_33_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_35_776337487.dbf
-rw-r----- 1 oracle oinstall 3584 Mar 14 13:26 1_34_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_36_776337487.dbf

Filed Under: oracle, RMAN

Some more articles you might also be interested in …

  1. How to Use real-time query to access data on a physical standby database
  2. Deleting duplicate records from a table
  3. How to quiesce an Oracle 12c RAC database
  4. Cron Script does not Execute as Expected from crontab – Troubleshoot
  5. Dynamic Oracle Net Server Tracing
  6. Oracle Tablespace Transport for a Single Partition
  7. How to Backup and Restore Java Classes and Privileges only in Oracle Database
  8. How to recreate Control file in Oracle Database
  9. How To Create Device Alias For ASM Disks Using mknod On Linux/Unix
  10. Oracle ASM – How ASM Disk Resync Works

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright