Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to PDB in Oracle 12c

I'm running a fresh installation of Oracle 12c on Solaris 10 and I can connect to the CDB using toad just fine, please tell me how can I now connect to the PDB database named PDBORCL as mentioned in the guide: https://oracle-base.com/articles/12c/multitenant-connecting-to-cdb-and-pdb-12cr1

Following are the contents of my tnsnames.ora file:

# tnsnames.ora Network Configuration File: /bkofa/oracle/app/oracle  

/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL12 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl12)
    )
  )
pdbORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdborcl)
    )
  )

Here are the contents of my listener.ora file:

# listener.ora Network Configuration File: /bkofa/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl12)
      (SID_NAME = orcl12)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = pdborcl)      
      (SID_NAME = pdborcl)
    )
  )

These are the containers by the way:

SELECT name, pdb    
FROM   v$services    
ORDER BY name;    

NAME              PDB    

SYS$BACKGROUND    CDB$ROOT    
SYS$USERS         CDB$ROOT    
orcl12            CDB$ROOT    
orcl12XDB         CDB$ROOT    
pdborcl           PDBORCL    

Still when I try to connect to PDB using any combination of commands this is what I get:

bash-3.2$ lsnrctl status  

LSNRCTL for Solaris: Version 12.1.0.2.0 - Production on 13-APR-2016 15:42:28  

Copyright (c) 1991, 2014, Oracle.  All rights reserved.  

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=afxortsts)(PORT=1523)))  
STATUS of the LISTENER  
------------------------  
Alias                     LISTENER  
Version                   TNSLSNR for Solaris: Version 12.1.0.2.0 - Production  
Start Date                12-APR-2016 13:56:56  
Uptime                    1 days 1 hr. 45 min. 36 sec  
Trace Level               off  
Security                  ON: Local OS Authentication  
SNMP                      OFF  
Listener Parameter File   /bkofa/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora  
Listener Log File         /bkofa/oracle/app/oracle/diag/tnslsnr/afxortsts/listener/alert/log.xml  
Listening Endpoints Summary...  
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=afxortsts)(PORT=1523)))  
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))  
Services Summary...  
Service "orcl12" has 1 instance(s).  
  Instance "orcl12", status UNKNOWN, has 1 handler(s) for this service...  
Service "pdborcl" has 1 instance(s).  
  Instance "pdborcl", status UNKNOWN, has 1 handler(s) for this service...  
The command completed successfully  
bash-3.2$ sqlplus '/ as sysdba'  

SQL*Plus: Release 12.1.0.2.0 Production on Wed Apr 13 15:42:44 2016  

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


Connected to:  
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production  
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options  

SQL> connect sys/[email protected]:1523/pdborcl as sysdba  
ERROR:  
ORA-01017: invalid username/password; logon denied  


Warning: You are no longer connected to ORACLE.  
SQL> connect sys@pdborcl  
Enter password:  
ERROR:  
ORA-01034: ORACLE not available  
ORA-27101: shared memory realm does not exist  
SVR4 Error: 2: No such file or directory  
Additional information: 2581  
Additional information: -2057892281  
Process ID: 0  
Session ID: 0 Serial number: 0  


SQL> connect [email protected]:1523/pdborcl as sysdba  
ERROR:  
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA  


SQL>  

Oh I should make this clear that I'm using port 1523 because there is another instance of older Oracle 10g already running on the system that uses this port so I wanted to avoid any conflict with that.

like image 252
Dashing Boy Avatar asked Jan 20 '26 12:01

Dashing Boy


1 Answers

You should not declare the services in the SID_LIST_LISTENER. Especially the pdborcl which is not an instance but a service within the instance. So remove this part:

(SID_DESC =
  (GLOBAL_DBNAME = pdborcl)      
  (SID_NAME = pdborcl)
)

The instance should register itself to the listener. If not done, you should, when connected to the CDB:

alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=afxortsts)(PORT=1523))) ';
alter system register;
like image 95
FranckPachot Avatar answered Jan 23 '26 20:01

FranckPachot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!