Tuesday 28 August 2018

Unable to connect to PDB | ORA-12154 ORA-12518 | Oracle 12c

ORA-12154: TNS:could not resolve the connect identifier specified | ORA-12518: TNS:listener could not hand off client connection


ORA-12154 and ORA-12154 generating when you are having issues with database connectivity whenever you try to login into your database. In my scenario, I was trying to install and configure Oracle Enterprise Manager 12c on my local system for pratice purposes and for that I had installed repository database named as EMCTLDB. This is a 12c database where EMCTLDB is the CDB name and EMCTLPDB is the PDB name. After the database was installed, I made the entries in the LISTENER.ORA and TNSNAMES.ORA like this,


LISTENER.ORA

(SID_DESC =
      (GLOBAL_DBNAME = emctldb)
      (ORACLE_HOME = F:\app\parain\product\12.1.0\dbhome_1)
      (SID_NAME = emctldb)
    )

(SID_DESC =
      (GLOBAL_DBNAME = emctlpdb)
      (ORACLE_HOME = F:\app\parain\product\12.1.0\dbhome_1)
      (SID_NAME = emctlpdb)
    )


TNSNAMES.ORA

EMCTLDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = PARAIN0.corpnet.ifsworld.com)(PORT = 1527))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = emctldb)
    )
  )


EMCTLPDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = PARAIN0.corpnet.ifsworld.com)(PORT = 1527))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = emctlpdb)
    )
  )

and then I restarted the LISTENER and checked for the status

F:\app\parain\diag\rdbms\emctldb\emctldb\trace>lsnrctl status listener2

LSNRCTL for 64-bit Windows: Version 12.1.0.2.0 - Production on 28-AUG-2018 12:49:24

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PARAIN0.corpnet.ifsworld.com)(PORT=1527)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER2
Version                   TNSLSNR for 64-bit Windows: Version 12.1.0.2.0 - Production
Start Date                28-AUG-2018 10:57:22
Uptime                    0 days 1 hr. 52 min. 6 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   F:\app\parain\product\12.1.0\dbhome_1\network\admin\listener.ora
Listener Log File         F:\app\parain\diag\tnslsnr\PARAIN0\listener2\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PARAIN0.corpnet.ifsworld.com)(PORT=1527)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1527ipc)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "emctldb" has 1 instance(s).
  Instance "emctldb", status UNKNOWN, has 1 handler(s) for this service...
Service "emctlpdb" has 1 instance(s).
  Instance "emctlpdb", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

The status for both the EMCTLDB and EMCTLPDB Instances was showing UNKNOWN. My main concern was with the PDB i.e. EMCTLPDB because I needed the same to use as repository database for my Enterprise Manager Setup. So I tried to use TNSPING to check for the connectivity and everything was good here,

C:\Users\parain>tnsping emctlpdb

TNS Ping Utility for 64-bit Windows: Version 12.1.0.2.0 - Production on 28-AUG-2018 11:56:45

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

Used parameter files:
F:\app\parain\product\12.1.0\dbhome_1\NETWORK\ADMIN\sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = PARAIN0.corpnet.ifsworld.com)(PORT = 1527)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = emctlpdb)))
OK (0 msec)

C:\Users\parain>

But when I tried to login to the database, it failed with ORA-12154 and ORA-12518

C:\Users\parain>sqlplus system@emctlpdb

SQL*Plus: Release 12.1.0.2.0 Production on Tue Aug 28 11:40:17 2018

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

Enter password:
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


C:\Users\parain>sqlplus sys@emctlpdb as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Aug 28 11:42:39 2018

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

Enter password:
ERROR:
ORA-12518: TNS:listener could not hand off client connection


Enter user-name: system@emctlpdb
Enter password:
ERROR:
ORA-12518: TNS:listener could not hand off client connection

After a lot of searching in GOOGLE I got the idea of dynamic registration with LISTENER and since I was able to login to my CBD i.e. EMCTLDB, I did this

SQL*Plus: Release 12.1.0.2.0 Production on Tue Aug 28 12:54:46 2018

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

Enter password:

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> show parameter local_listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string

SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=tcp)(HOST=PARAIN0.corpnet.ifsworld.com)(PORT=1527))';

System altered.

SQL> quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

And then I reloaded my LISTENER again

F:\app\parain\diag\rdbms\emctldb\emctldb\trace>lsnrctl reload listener2

LSNRCTL for 64-bit Windows: Version 12.1.0.2.0 - Production on 28-AUG-2018 12:56:16

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PARAIN0.corpnet.ifsworld.com)(PORT=1527)))
The command completed successfully

This time there were 2 instances for the services EMCTLDB and EMCTLPDB, one with UNKNOWN state and other with READY. This might be because I used both STATIC and DYNAMIC registration with LISTENER for the connectivity.

F:\app\parain\diag\rdbms\emctldb\emctldb\trace>lsnrctl status listener2

LSNRCTL for 64-bit Windows: Version 12.1.0.2.0 - Production on 28-AUG-2018 12:56:19

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PARAIN0.corpnet.ifsworld.com)(PORT=1527)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER2
Version                   TNSLSNR for 64-bit Windows: Version 12.1.0.2.0 - Production
Start Date                28-AUG-2018 10:57:22
Uptime                    0 days 1 hr. 59 min. 1 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   F:\app\parain\product\12.1.0\dbhome_1\network\admin\listener.ora
Listener Log File         F:\app\parain\diag\tnslsnr\PARAIN0\listener2\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PARAIN0.corpnet.ifsworld.com)(PORT=1527)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1527ipc)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "emctldb" has 2 instance(s).
  Instance "emctldb", status UNKNOWN, has 1 handler(s) for this service...
  Instance "emctldb", status READY, has 1 handler(s) for this service...
Service "emctldbXDB" has 1 instance(s).
  Instance "emctldb", status READY, has 1 handler(s) for this service...
Service "emctlpdb" has 2 instance(s).
  Instance "emctldb", status READY, has 1 handler(s) for this service...
  Instance "emctlpdb", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

And YES, I was able to connect to my PDB this time.

F:\app\parain\diag\rdbms\emctldb\emctldb\trace>sqlplus sys@emctlpdb as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Aug 28 12:56:35 2018

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

Enter password:

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>

I hope this helps !!

1 comment:

  1. Thank you for this blog. It helped me to resolve my issue, for which i was struggling for last 2 days.

    ReplyDelete