Please see my other blog for Oracle EBusiness Suite Posts - EBMentors

Search This Blog

Note: All the posts are based on practical approach avoiding lengthy theory. All have been tested on some development servers. Please don’t test any post on production servers until you are sure.

Tuesday, April 02, 2013

Deleting obsolete rman backup information from controlfile

Scenario:
We took database backup disk including controlfile from production server to refresh a staging server for application testing purpose. On production server TAPE (Netbackup) already configured. After copying the RMAN backup files to Stage DB Server, upon restore when we checked database backups it was showing the TAPE backups also. So we deleted the backups.



RMAN> delete backup completed before 'sysdate-7';
backup piece handle=D:\RMANBACKUP\DB\HOMEDB_DB_C1NVIH3N_5505_1 RECID=5387 STAMP=804865144
deleted backup piece
...

...
 backup piece handle=D:\RMANBACKUP\DB\AL_CJNVIKO6_1_1 RECID=5404 STAMP=804868870
deleted backup piece
backup piece handle=D:\RMANBACKUP\CONTROLFILE\CONTORLFILE_C-1547250382-20130116-04 RECID=5405 STAMP=804868878

Deleted 17 objects
RMAN> list backup summary;

This is output
------------------------------------------------------------------------------------------------------------
List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
5186    B  F  A SBT_TAPE    26-DEC-12       1       1       NO         TAG20121226T070014
....

....
5353    B  F  A SBT_TAPE    14-JAN-13       1       1       NO         TAG20130114T072520
RMAN> exit

Recovery Manager complete.
Still there are old backups in inventory because we don't have sbt_tape configured on this server so we cannot delete these backups from inventory. To delete info from controlfile we need to recreate controlfile.
C:\Users\inam.HOME>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Jan 21 07:48:59 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter database backup controlfile to trace as 'd:\control22.txt';

Database altered.

SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      D:\APP\INAM\ORADATA\HOMEDB\CO
                                                 NTROL01.CTL
control_management_pack_access       string      DIAGNOSTIC+TUNING

shutdown the database

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

Start DB in nomount state

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1553379328 bytes
Fixed Size                  2255464 bytes
Variable Size            1224738200 bytes
Database Buffers          318767104 bytes
Redo Buffers                7618560 bytes

SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      D:\APP\INAM\ORADATA\
HOMEDB\CO
                                                 NTROL01.CTL
control_management_pack_access       string      DIAGNOSTIC+TUNING
SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string


copy these lines from output file created with alter database backup controlfile to trace command and paste in sqlplus prompt


SQL> CREATE CONTROLFILE REUSE DATABASE "
HOMEDB" NORESETLOGS  ARCHIVELOG
  2      MAXLOGFILES 192
  3      MAXLOGMEMBERS 3
  4      MAXDATAFILES 1024
  5      MAXINSTANCES 32
  6      MAXLOGHISTORY 5840
  7  LOGFILE
  8    GROUP 1 'D:\APP\INAM\FAST_RECOVERY_AREA\
HOMEDB\ONLINELOG\O1_MF_1_8HB4BG1H_.LOG'  SIZE 500M BLOCKSIZE 512,
  9    GROUP 2 'D:\APP\
INAM\FAST_RECOVERY_AREA\HOMEDB\ONLINELOG\O1_MF_2_8HB4767Z_.LOG'  SIZE 500M BLOCKSIZE 512,
 10    GROUP 3 'D:\APP\
INAM\FAST_RECOVERY_AREA\HOMEDB\ONLINELOG\O1_MF_3_8HB4BLLD_.LOG'  SIZE 500M BLOCKSIZE 512,
 11    GROUP 4 'D:\APP\
INAM\FAST_RECOVERY_AREA\HOME\ONLINELOG\O1_MF_4_8HB4B33G_.LOG'  SIZE 500M BLOCKSIZE 512
 12  -- STANDBY LOGFILE
 13  DATAFILE
 14    'D:\APP\
INAM\ORADATA\HOMEDB\SYSTEM.256.770482167',
 15    'D:\APP\
INAM\ORADATA\HOMEDB\SYSAUX.257.770482167',
 16    'D:\APP\
INAM\ORADATA\HOMEDB\UNDOTBS1.258.770482167',
 17    'D:\APP\
INAM\ORADATA\HOMEDB\USERS.259.770482167',
 18    'D:\APP\
INAM\ORADATA\HOMEDB\EXAMPLE.264.770482273',
 19    'D:\APP\
INAM\ORADATA\HOMEDB\UNDOTBS2.265.770482381',
 20    'D:\APP\
INAM\ORADATA\HOMEDB\HOMELOG01.DBF',
 21    'D:\APP\
INAM\ORADATA\HOMEDB\TEST_NETBKUP.DBF',
 22    'D:\APP\
INAM\ORADATA\HOMEDB\RECOP1.DBF',
 23    'D:\APP\
INAM\ORADATA\HOMEDB\HOMELOG02.DBF',
 24    'D:\APP\
INAM\ORADATA\HOMEDB\HOME_TS01.DBF',
 25    'D:\APP\
INAM\ORADATA\HOMEDB\HOME_TS02.DBF',
 26    'D:\APP\
INAM\ORADATA\HOMEDB\HOME_TS03.DBF',
 27    'D:\APP\
INAM\ORADATA\HOMEDB\HOME_TS04.DBF',
 28    'D:\APP\
INAM\ORADATA\HOMEDB\HOME_TS05.DBF',
 29    'D:\APP\
INAM\ORADATA\HOMEDB\UNDOTBS1.278.770746419',
 30    'D:\APP\
INAM\ORADATA\HOMEDB\UNDOTBS2.279.770746495'
 31  CHARACTER SET AR8ISO8859P6
 32  ;

Control file created.

SQL> alter database open;

Database altered.

SQL> 

No comments: