12c Multitenant: How to Connect to PDBs with Same Name in Different CDBs (Doc ID 2123106.1)

12c Multitenant: How to Connect to PDBs with Same Name in Different CDBs (Doc ID 2123106.1)

19c还可以: set ORACLE_PDB_SID=pdb1

12c Multitenant: How to Connect to PDBs with Same Name in Different CDBs (Doc ID 2123106.1)

You have  duplicated 2 auxiliary database instances from a single target CDB container database.
Both instances reside on the same server and are registered against the same listener.

How can I connect to a specific PDB with the same name but configured in different CDBs?

 

You'll find that a single PDB service is registered under 2 instances.  This is how LSNRCTL services
might look:

Services Summary...

The command completed successfully
 Service "PDB_1" has 2 instance(s).  <==Pluggable database created in each container database

Instance "cdb_1", status READY, has 1 handler(s) for this service...     <==Container database1
Handler(s):      "DEDICATED" established:63112 refused:0 state:ready         

Instance "cdb_2", status READY, has 1 handler(s) for this service...     <==Container database2
Handler(s):      "DEDICATED" established:349293 refused:0 state:ready       


 

SOLUTION



If you want to connect to a PDB service in a specific CDB instance, you can specify the INSTANCE_NAME in the
TNS connect string.  Set INSTANCE_NAME to  point to the specific container database name.  

Note that in our example, the SERVICE_NAME matches the PDB name.  The INSTANCE_NAME in each TNS connect
string is set to each CDB instance name.

PDB_1=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yourhosthere)(PORT = 1521))
        (CONNECT_DATA =
           (SERVER = DEDICATED)
           (SERVICE_NAME = PDB_1) (INSTANCE_NAME = cdb_1)
        )
    )

PDB_2=
   (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = yourhosthere)(PORT = 1521))
         (CONNECT_DATA =
            (SERVER = DEDICATED)
            (SERVICE_NAME = PDB_1) (INSTANCE_NAME = cdb_2)
       )
    )

https://www.orafaq.com/node/2823