RMAN-06004: Oracle error from recovery catalog database: RMAN-20005: target database name is ambiguous

The following errors occur in the trace file when duplicate a database:

MAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 05/13/2025 21:01:07
RMAN-05501: aborting duplication of target database
RMAN-06004: Oracle error from recovery catalog database: RMAN-20005: target database name is ambiguous
DBGMISC: ENTERED krmkursr [21:01:13.976]
DBGMISC: EXITED krmkursr [21:01:13.976] elapsed time [00:00:00:00.000]
-------------------------------------------------------------------------------
Trace Bucket Dump End: rman trace

RESOLUTION

If the source database is still running, the run the following the sql to get the dbid:

SQL>  select dbid, name from v$database;

DBID NAME
---------- ---------
1234567890 TESTDB

Otherwise logon to RMAN catalog database, and

SQL>select rbs.db_key
, rd.name
, RBS.DB_ID
, rbs.bs_key
, rbs.recid
, rbs.stamp
, rbs.backup_type
, rbs.start_time, status
from rc_backup_set rbs, rc_database rd
where rbs.db_key=rd.db_key
and rbs.db_id=rd.dbid
and rd.name='TESTDB' ;

DB_KEY NAME DB_ID BS_KEY RECID STAMP B START_TIM S
---------- -------- ---------- ---------- ---------- ---------- - ---------
86602789 TESTDB 1234567890 104349946 5934 1201017848 L 13-MAY-25 A

Finally, in RMAN script add the following:

set dbid=1234567890;
duplicate database from testdb to devdb until time "TO_DATE('2025-05-05 09:00:00','YYYY-MM-DD HH24:MI:SS'

RMAN-03002 RMAN-05501 RMAN-03015 RMAN-03009 ORA-17629 ORA-17627 ORA-27101 ORA-17629 duplicate target database for standby from active database

In 12c , try to duplicate a standby database with below errors:

channel ORA_DISK_1: SID=158 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 01/15/2019 18:35:32
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 01/15/2019 18:35:32
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3651
Additional information: -603812709
ORA-17629: Cannot connect to the remote database server

WORKAROUND

In tnsnames.ora of both primary and standby database server, add  “(UR = A)” for the standby database entry :

TESTDBSTY =
(DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
   (CONNECT_DATA = (SERVICE_NAME = TESTDBSTY)(UR=A))
)