Saturday, March 19, 2016

ORA-12505 TNS:listener does not currently know of SID after 12c DBCA

[The problem]

Created a portable database RCATPDB1 and a contained database RCATT using 12.1.0.2 dbca, but not able to connect to it through LISTENER, however tnsping returns okay.

$ tnsping RCATT

TNS Ping Utility for Solaris: Version 12.1.0.2.0 - Production on 11-MAR-2016 14:11:07

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

Used parameter files:
/software/orarman/product/12.1.0/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = testdbdev)(PORT = 1555)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RCATT)))
OK (10 msec)


$ sqlplus system/dsafdsa@RCATPDB1

SQL*Plus: Release 12.1.0.2.0 Production on Fri Mar 11 16:35:34 2016

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

ERROR:
ORA-12505: TNS:listener does not currently know of SID given in connect
descriptor

[Troubleshooting]
Googled and find this is the exact same problem as mine. 

[Solution]

Then the solution is define local_listener in pfile for dynamic registration.

Define the listener in tnsnames.ora

LISTENER_RCATT =
  (ADDRESS = (PROTOCOL = TCP)(HOST = testdbdev)(PORT = 1555))

RCATT =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = testdbdev)(PORT = 1555))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = RCATT)
    )
  )

RCATPDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = testdbdev)(PORT = 1555))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = RCATPDB1)
    )


SQL> show parameter local_listen

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



SQL> alter system set local_listener='RCATT' scope=both;

System altered.


SQL> alter system register;

System altered.


$ lsnrctl service LISTENER_RCATT

LSNRCTL for Solaris: Version 12.1.0.2.0 - Production on 11-MAR-2016 16:44:13

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=testdbdev)(PORT=1555)))
Services Summary...
Service "RCATT" has 1 instance(s).
  Instance "RCATT", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "RCATTXDB" has 1 instance(s).
  Instance "RCATT", status READY, has 1 handler(s) for this service...
    Handler(s):
      "D000" established:0 refused:0 current:0 max:1022 state:ready
         DISPATCHER
         (ADDRESS=(PROTOCOL=tcp)(HOST=testdbdev)(PORT=41100))
Service "rcatpdb1" has 1 instance(s).
  Instance "RCATT", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
The command completed successfully



$ sqlplus  system@RCATT

SQL*Plus: Release 12.1.0.2.0 Production on Fri Mar 11 16:46:51 2016

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

Last Successful login time: Wed Mar 09 2016 12:01:10 +08:00

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> exit
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
$ sqlplus  system@RCATPDB1

SQL*Plus: Release 12.1.0.2.0 Production on Fri Mar 11 16:46:57 2016

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

Last Successful login time: Fri Mar 11 2016 16:46:51 +08:00

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> EXIT
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
$ tnsping RCATT

TNS Ping Utility for Solaris: Version 12.1.0.2.0 - Production on 11-MAR-2016 16:47:04

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

Used parameter files:
/software/orarman/product/12.1.0/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = testdbdev)(PORT = 1555)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RCATT)))
OK (10 msec)
$ tnsping RCATPDB1

TNS Ping Utility for Solaris: Version 12.1.0.2.0 - Production on 11-MAR-2016 16:47:12

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

Used parameter files:
/software/orarman/product/12.1.0/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = testdbdev)(PORT = 1555)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RCATPDB1)))
OK (10 msec)