RMAN-06004: ORACLE error from recovery catalog database: RMAN-20005: target database name is ambiguous报错修复

休假前,同事在异地恢复一套数据库时报错:RMAN-06004: ORACLE error from recovery catalog database: RMAN-20005: target database name is ambiguous。以下内容为还原报错场景与修复手段:

ora11g@Travelskydba-ora dbs]$ rman target / catalog cata_user/oracle@ora977b

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Sep 4 10:13:01 2020

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

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

RMAN> restore controlfile;

Starting restore at 04-SEP-20
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/04/2020 10:13:08
RMAN-12010: automatic channel allocation initialization failed
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20005: target database name is ambiguous


SQL> select * from rc_database;

    DB_KEY  DBINC_KEY       DBID NAME     RESETLOGS_CHANGE# RESETLOGS_TIME
---------- ---------- ---------- -------- ----------------- -----------------
         1          2 1663399389 PROD3                    1 20200904 09:23:41
        49         50 1663401346 PROD3                    1 20200904 09:56:18
		

报错根因为此数据库在CATALOG库中注册了2次(期间重新建立过DB-create d atabase操作),所以在备份还原controfile时需要指定dbid:

RMAN> set dbid=1663401346       

executing command: SET DBID
database name is "PROD3" and DBID is 1663401346

RMAN> restore controlfile;

Starting restore at 04-SEP-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=156 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: reading from backup piece /opt/app/ora11g/orabase/product/11.2.0/db_1/dbs/03v9idof_1_1
channel ORA_DISK_1: piece handle=/opt/app/ora11g/orabase/product/11.2.0/db_1/dbs/03v9idof_1_1 tag=TAG20200904T100809
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/app/ora11g/albert/controlfile1.ctl
output file name=/opt/app/ora11g/albert/controlfile2.ctl
Finished restore at 04-SEP-20

为了避免后续再次出现此类问题,可以将已经废弃的数据库dbid从catalog中unregister,避免每次set dbid操作

[ora11g@Travelskydba-ora app]$ rman target / catalog cata_user/oracle@travelskydba

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Sep 4 10:35:56 2020

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

connected to target database (not started)
connected to recovery catalog database

RMAN> set dbid=1663399389 

executing command: SET DBID
database name is "PROD3" and DBID is 1663399389

RMAN> unregister database;

database name is "PROD3" and DBID is 1663399389

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

RMAN> 

SQL> select * from rc_database;

    DB_KEY  DBINC_KEY       DBID NAME     RESETLOGS_CHANGE# RESETLOGS_TIME
---------- ---------- ---------- -------- ----------------- -----------------
        49         50 1663401346 PROD3                    1 20200904 09:56:18

SQL> 

[ora11g@Travelskydba-ora dbs]$ rman target / catalog cata_user/oracle@travelskydba

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Sep 4 10:37:32 2020

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

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

RMAN> restore controlfile;

Starting restore at 04-SEP-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=156 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: reading from backup piece /opt/app/ora11g/orabase/product/11.2.0/db_1/dbs/03v9idof_1_1
channel ORA_DISK_1: piece handle=/opt/app/ora11g/orabase/product/11.2.0/db_1/dbs/03v9idof_1_1 tag=TAG20200904T100809
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/app/ora11g/albert/controlfile1.ctl
output file name=/opt/app/ora11g/albert/controlfile2.ctl
Finished restore at 04-SEP-20