Saturday, December 5, 2009

RMAN-20005 & How to unregister database

If more than one database with same database name, but different DBID, registered to the same calalog, during the restoration, must set DBID, otherwise, "RMAN-20005: target database name is ambiguous" error will raise.


$ rman target / catalog rman/xxxxx@rmandb

Recovery Manager: Release 10.2.0.4.0 - Production on Thu Dec 3 11:56:56 2009

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

connected to target database: hktst (not mounted)
connected to recovery catalog database

RMAN> run {
2> allocate channel ch0 device type 'sbt';
3> restore controlfile;
4> }

allocated channel: ch0
channel ch0: sid=147 instance=hkdrt1 devtype=SBT_TAPE
channel ch0: Veritas NetBackup for Oracle - Release 6.5 (2009050106)

Starting restore at 2009-DEC-03 11:57:20

released channel: ch0
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/03/2009 11:57:20
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20005: target database name is ambiguous

RMAN> exit


select * from rc_database where name='HKTST' order by resetlogs_time;


DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- -------- ----------------- ---------
29211 29212 1902399835 HKTST 602821 15-OCT-09
30110 52364 1902498142 HKTST 841865 21-OCT-09
36494 221103 1902647353 HKTST 5191383 03-DEC-09


How to unresgister a database


man catalog rman/xxxxx@rmandb

Recovery Manager: Release 10.2.0.4.0 - Production on Fri Dec 4 11:11:14 2009

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

connected to recovery catalog database

RMAN> set dbid 1902399835;

executing command: SET DBID
database name is "HKTST" and DBID is 1902399835

RMAN> unregister database;

database name is "HKTST" and DBID is 1902399835

Do you really want to unregister the database (enter YES or NO)? yes
database unregistered from the recovery catalog



RMAN> set dbid 1902498142

executing command: SET DBID
database name is "HKTST" and DBID is 1902498142

RMAN> unregister database noprompt;

database name is "HKTST" and DBID is 1902498142
database unregistered from the recovery catalog


select * from rc_database where name='HKTST' order by resetlogs_time;

DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- -------- ----------------- ---------
36494 221103 1902647353 HKTST 5191383 03-DEC-09


1 row selected.