How to connect to pluggable database using ipc in Oracle XE 18c?
Question
Here is my listener configuration:
LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 20-NOV-2020 20:01:25
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=NoteBook)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Start Date 20-NOV-2020 20:00:55
Uptime 0 days 0 hr. 0 min. 29 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/NoteBook/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=NoteBook)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=127.0.0.1)(PORT=5500))(Security=(my_wallet_directory=/opt/oracle/product/18c/dbhomeXE/admin/XE/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "XE" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "b470a0c2708d9acee0530401a8c035ac" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "xepdb1" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully
I can connect to xepdb1 through tcp using sqlplus user/password@NoteBook/xepdb1
, however, if I use use ipc (sqlplus user/password@xepdb1
) to connect, it fails with an error ORA-12154: TNS:could not resolve the connect identifier specified
.
How can I connect to a pluggable database using ipc?
Solution
If you connect by
sqlplus user/password@NoteBook:1521/xepdb1
then you use EZconnect, this is a TCP connect where "NoteBook" is the server, "1521" is the port and "xepdb1" is the service. "1521" is the default for port so you can omit it. But the protocol is TCP. If you want to use the IPC connection defined in the listener than you have to use a tnsnames.ora file. This is not possible with EZconnect.
In this tnsnames.ora file you have to have an entry similar to
xepdb1=(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC))(CONNECT_DATA=(SERVICE_NAME=xepdb1)))
Now you can connect as
sqlplus user/password@xepdb1
In Linux you can skip the tnsname.ora file and yuse the following
sqlplus user/password@'(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC))(CONNECT_DATA=(SERVICE_NAME=xepdb1)))'
So you have to quote the string. In Windows there is a similar way to do it.
The name of the key you use in the listner file for the IPC connection can be chosen arbitrary, but of course you have to use the same key in your connection.
OTHER TIPS
"if I use use ipc (sqlplus user/password@xepdb1) "
That's not IPC, that's tcp. It tries to find the entry for 'xepdb1' in the client's tnsnames.ora file. Then it tries to construct a tcp packet from the information found there, and send that packet to the specified host and port, where - hopefully - there is a listener. Your error means that it could not find the specified entry in the client's tnsnames.ora.