{"id":4568,"date":"2021-05-12T09:00:52","date_gmt":"2021-05-12T09:00:52","guid":{"rendered":"https:\/\/swiv.com.br\/configuring-oci-tns-entry-for-pdbs\/"},"modified":"2026-05-27T20:02:32","modified_gmt":"2026-05-27T19:02:32","slug":"configuring-oci-tns-entry-for-pdbs","status":"publish","type":"post","link":"https:\/\/swiv.com.br\/index.php\/2021\/05\/12\/configuring-oci-tns-entry-for-pdbs\/","title":{"rendered":"Configuring OCI TNS Entry for PDBs"},"content":{"rendered":"\n<p>Ao criarmos nosso banco de dados em arquitetura Multitenant no OCI, vimos que a string de conex\u00e3o no arquivo tnsnames.ora possuir\u00e1 apenas o CDB$ROOT, como abaixo:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;opc@luxor ~]$ sudo su - oracle\nLast login: Wed May 12 08:06:03 UTC 2021\n&#x5B;oracle@luxor ~]$ cd $ORACLE_HOME\/network\/admin\n&#x5B;oracle@luxor admin]$ cat tnsnames.ora\n# tnsnames.ora Network Configuration File: \/u01\/app\/oracle\/product\/12.2.0.1\/dbhome_1\/network\/admin\/tnsnames.ora\n# Generated by Oracle configuration tools.\n \nLISTENER_CORTEX =\n  (ADDRESS = (PROTOCOL = TCP)(HOST = luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT = 1521))\n \n \nCORTEX_PHX1HB =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = CORTEX_phx1hb.luxorsubnet.luxorvcn.oraclevcn.com)\n    )\n  )\n<\/pre><\/div>\n\n\n<p>Realizando teste de conex\u00e3o ao CDB$ROOT usando o TNS:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@luxor admin]$ tnsping CORTEX_PHX1HB\n \nTNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 12-MAY-2021 08:07:47\n \nCopyright (c) 1997, 2016, Oracle.  All rights reserved.\n \nUsed parameter files:\n\/u01\/app\/oracle\/product\/12.2.0.1\/dbhome_1\/network\/admin\/sqlnet.ora\n \n \nUsed TNSNAMES adapter to resolve the alias\nAttempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = CORTEX_phx1hb.luxorsubnet.luxorvcn.oraclevcn.com)))\nOK (0 msec)\n&#x5B;oracle@luxor admin]$ sqlplus system@CORTEX_PHX1HB\n \nSQL*Plus: Release 12.2.0.1.0 Production on Wed May 12 08:07:55 2021\n \nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n \nEnter password:\nLast Successful login time: Mon Oct 19 2020 15:40:19 +00:00\n \nConnected to:\nOracle Database 12c EE Extreme Perf Release 12.2.0.1.0 - 64bit Production\n \nSQL&gt; SHOW USER;\nUSER is &quot;SYSTEM&quot;\n<\/pre><\/div>\n\n\n<p>Vamos coletar as informa\u00e7\u00f5es necess\u00e1rias para criarmos a nova string de conex\u00e3o do PDB. Por\u00e9m, percebo que o service name exibido no PDB \u00e9 o mesmo do CDB:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; SELECT NAME,OPEN_MODE FROM V$PDBS;\n \nNAME\n--------------------------------------------------------------------------------\nOPEN_MODE\n----------\nPDB$SEED\nREAD ONLY\n \nHIPOFISE1\nREAD WRITE\n \n \nSQL&gt; ALTER SESSION SET CONTAINER=HIPOFISE1;\n \nSession altered.\n \nSQL&gt; sho parameter service\n \nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\nservice_names                        string      CORTEX_phx1hb.luxorsubnet.luxo\n                                                 rvcn.oraclevcn.com\n<\/pre><\/div>\n\n\n<p>Desse modo, alterarei o service name manualmente, colocando como prefixo o nome do PDB, conforme exemplo:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@luxor admin]$ cat tnsnames.ora\n# tnsnames.ora Network Configuration File: \/u01\/app\/oracle\/product\/12.2.0.1\/dbhome_1\/network\/admin\/tnsnames.ora\n# Generated by Oracle configuration tools.\n \nLISTENER_CORTEX =\n  (ADDRESS = (PROTOCOL = TCP)(HOST = luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT = 1521))\n \n \nCORTEX_PHX1HB =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = CORTEX_phx1hb.luxorsubnet.luxorvcn.oraclevcn.com)\n    )\n  )\n \nHIPOFISE1 =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = HIPOFISE1_phx1hb.luxorsubnet.luxorvcn.oraclevcn.com)\n    )\n  )\n<\/pre><\/div>\n\n\n<p>Ao tentar conectar no PDB, o seguinte erro \u00e9 exibido:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@luxor admin]$ sqlplus system@HIPOFISE1\n \nSQL*Plus: Release 12.2.0.1.0 Production on Wed May 12 08:22:57 2021\n \nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n \nEnter password:\nERROR:\nORA-12514: TNS:listener does not currently know of service requested in connect\ndescriptor\n<\/pre><\/div>\n\n<p>Ap\u00f3s algumas pesquisas, chego no Oracle Note \\&#8221;<strong>Connection To an OCI DBCS PDB Failed With \\&#8221;ORA-12154: TNS:could not resolve the connect identifier specified\\&#8221; (Doc ID 2674380.1)<\/strong>\\&#8221; (link <a href=\"https:\/\/support.oracle.com\/epmos\/faces\/DocumentDisplay?_afrLoop=307148937300065&amp;id=2674380.1&amp;displayIndex=1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=lkjkukc53_53#CAUSE\" target=\"\\&quot;_blank\\&quot;\" rel=\"\\&quot;noreferrer noopener\" noopener=\"\">AQUI<\/a>), que me traz a solu\u00e7\u00e3o: adicionar a linha \\&#8221;NAMES.DIRECTORY_PATH = (TNSNAMES, EZCONNECT)\\&#8221; no arquivo sqlnet.ora:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@luxor admin]$ cp sqlnet.ora sqlnet.ora.bkp\n&#x5B;oracle@luxor admin]$ cat sqlnet.ora\nENCRYPTION_WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=\/opt\/oracle\/dcs\/commonstore\/wallets\/tde\/$ORACLE_UNQNAME)))\n \nSQLNET.ENCRYPTION_SERVER=REQUIRED\nSQLNET.CRYPTO_CHECKSUM_SERVER=REQUIRED\nSQLNET.ENCRYPTION_TYPES_SERVER=(AES256,AES192,AES128)\nSQLNET.CRYPTO_CHECKSUM_TYPES_SERVER=(SHA1)\nSQLNET.ENCRYPTION_CLIENT=REQUIRED\nSQLNET.CRYPTO_CHECKSUM_CLIENT=REQUIRED\nSQLNET.ENCRYPTION_TYPES_CLIENT=(AES256,AES192,AES128)\nSQLNET.CRYPTO_CHECKSUM_TYPES_CLIENT=(SHA1)\nNAMES.DIRECTORY_PATH = (TNSNAMES, EZCONNECT)\n<\/pre><\/div>\n\n\n<p>Ap\u00f3s isso, ao reinicializar o listener, os servi\u00e7os dos PDBs s\u00e3o exibidos (at\u00e9 de um segundo novo PDB que eu havia criado, enquanto fazia a investiga\u00e7\u00e3o do problema):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;opc@luxor ~]$ sudo su - grid\nLast login: Wed May 12 08:49:04 UTC 2021\n&#x5B;grid@luxor ~]$ lsnrctl stop\n \nLSNRCTL for Linux: Version 19.0.0.0.0 - Production on 12-MAY-2021 08:49:59\n \nCopyright (c) 1991, 2020, Oracle.  All rights reserved.\n \nConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))\nThe command completed successfully\n&#x5B;grid@luxor ~]$ lsnrctl start\n \nLSNRCTL for Linux: Version 19.0.0.0.0 - Production on 12-MAY-2021 08:50:05\n \nCopyright (c) 1991, 2020, Oracle.  All rights reserved.\n \nStarting \/u01\/app\/19.0.0.0\/grid\/bin\/tnslsnr: please wait...\n \nTNSLSNR for Linux: Version 19.0.0.0.0 - Production\nSystem parameter file is \/u01\/app\/19.0.0.0\/grid\/network\/admin\/listener.ora\nLog messages written to \/u01\/app\/grid\/diag\/tnslsnr\/luxor\/listener\/alert\/log.xml\nListening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))\n \nConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))\nSTATUS of the LISTENER\n------------------------\nAlias                     LISTENER\nVersion                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production\nStart Date                12-MAY-2021 08:50:06\nUptime                    0 days 0 hr. 0 min. 0 sec\nTrace Level               off\nSecurity                  ON: Local OS Authentication\nSNMP                      OFF\nListener Parameter File   \/u01\/app\/19.0.0.0\/grid\/network\/admin\/listener.ora\nListener Log File         \/u01\/app\/grid\/diag\/tnslsnr\/luxor\/listener\/alert\/log.xml\nListening Endpoints Summary...\n  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))\nThe listener supports no services\nThe command completed successfully\n&#x5B;grid@luxor ~]$ lsnrctl service\n \nLSNRCTL for Linux: Version 19.0.0.0.0 - Production on 12-MAY-2021 08:50:21\n \nCopyright (c) 1991, 2020, Oracle.  All rights reserved.\n \nConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))\nServices Summary...\nService &quot;CORTEXXDB.luxorsubnet.luxorvcn.oraclevcn.com&quot; has 1 instance(s).\n  Instance &quot;CORTEX&quot;, status READY, has 1 handler(s) for this service...\n    Handler(s):\n      &quot;D000&quot; established:0 refused:0 current:0 max:1022 state:ready\n         DISPATCHER &amp;lt;machine: luxor, pid: 8457&gt;\n         (ADDRESS=(PROTOCOL=tcp)(HOST=luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT=50057))\nService &quot;CORTEX_phx1hb.luxorsubnet.luxorvcn.oraclevcn.com&quot; has 1 instance(s).\n  Instance &quot;CORTEX&quot;, status READY, has 2 handler(s) for this service...\n    Handler(s):\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\nService &quot;c1cf6dcea12f134de0539501000a20c1.luxorsubnet.luxorvcn.oraclevcn.com&quot; has 1 instance(s).\n  Instance &quot;CORTEX&quot;, status READY, has 2 handler(s) for this service...\n    Handler(s):\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\nService &quot;c21efdff5eb40dcde0539501000ac2b8.luxorsubnet.luxorvcn.oraclevcn.com&quot; has 1 instance(s).\n  Instance &quot;CORTEX&quot;, status READY, has 2 handler(s) for this service...\n    Handler(s):\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\nService &quot;hipofise1.luxorsubnet.luxorvcn.oraclevcn.com&quot; has 1 instance(s).\n  Instance &quot;CORTEX&quot;, status READY, has 2 handler(s) for this service...\n    Handler(s):\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\nService &quot;hipofise2.luxorsubnet.luxorvcn.oraclevcn.com&quot; has 1 instance(s).\n  Instance &quot;CORTEX&quot;, status READY, has 2 handler(s) for this service...\n    Handler(s):\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\nThe command completed successfully\n&#x5B;grid@luxor ~]$\n<\/pre><\/div>\n\n\n<p>Ajustando o service name no arquivo tnsnames.ora:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@luxor admin]$ cat tnsnames.ora\n# tnsnames.ora Network Configuration File: \/u01\/app\/oracle\/product\/12.2.0.1\/dbhome_1\/network\/admin\/tnsnames.ora\n# Generated by Oracle configuration tools.\n \nLISTENER_CORTEX =\n  (ADDRESS = (PROTOCOL = TCP)(HOST = luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT = 1521))\n \n \nCORTEX_PHX1HB =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = CORTEX_phx1hb.luxorsubnet.luxorvcn.oraclevcn.com)\n    )\n  )\n \nHIPOFISE1 =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = luxor.luxorsubnet.luxorvcn.oraclevcn.com)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = HIPOFISE1.luxorsubnet.luxorvcn.oraclevcn.com)\n    )\n  )\n<\/pre><\/div>\n\n\n<p>Realizando teste, finalmente com sucesso:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@luxor admin]$ sqlplus system@HIPOFISE1\n \nSQL*Plus: Release 12.2.0.1.0 Production on Wed May 12 09:00:08 2021\n \nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n \nEnter password:\nLast Successful login time: Wed May 12 2021 08:59:34 +00:00\n \nConnected to:\nOracle Database 12c EE Extreme Perf Release 12.2.0.1.0 - 64bit Production\n \nSQL&gt; SELECT * FROM DUAL;\n \nD\n-\nX\n<\/pre><\/div>\n\n\n<p>Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laborat\u00f3rio pessoal para fins de aprendizado.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ao criarmos nosso banco de dados em arquitetura Multitenant no OCI, vimos que a string de conex\u00e3o no arquivo tnsnames.ora possuir\u00e1 apenas o CDB$ROOT, como abaixo: Realizando teste de conex\u00e3o ao CDB$ROOT usando o TNS: Vamos coletar as informa\u00e7\u00f5es necess\u00e1rias para criarmos a nova string de conex\u00e3o do PDB. Por\u00e9m, percebo que o service name [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-4568","post","type-post","status-publish","format-standard","hentry","category-oci"],"_links":{"self":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/4568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=4568"}],"version-history":[{"count":1,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/4568\/revisions"}],"predecessor-version":[{"id":9139,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/4568\/revisions\/9139"}],"wp:attachment":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=4568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=4568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=4568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}