{"id":3213,"date":"2021-03-29T07:47:27","date_gmt":"2021-03-29T07:47:27","guid":{"rendered":"https:\/\/swiv.com.br\/creating-a-pdb-by-recolating-a-pdb\/"},"modified":"2026-05-27T20:02:49","modified_gmt":"2026-05-27T19:02:49","slug":"creating-a-pdb-by-recolating-a-pdb","status":"publish","type":"post","link":"https:\/\/swiv.com.br\/index.php\/2021\/03\/29\/creating-a-pdb-by-recolating-a-pdb\/","title":{"rendered":"Creating a PDB by Recolating a PDB"},"content":{"rendered":"\n<p>A partir da release 12.2, a Oracle disponibilizou um recurso interessante para n\u00f3s, chamado relocate. Este, consiste basicamente na movimenta\u00e7\u00e3o de um PDB de um CDB para outro CDB, com um downtime m\u00ednimo que ser\u00e1 demonstrado neste artigo. Como eu s\u00f3 possuo um CDB de origem, farei a cria\u00e7\u00e3o do CDB de destino conforme 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;oracle@oel8 ~]$ export DISPLAY=192.168.0.104:0.0\n&#x5B;oracle@oel8 ~]$ dbca &amp;amp;\n&#x5B;1] 9723\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-246.png\" alt=\"\" class=\"wp-image-7959\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-247.png\" alt=\"\" class=\"wp-image-7960\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-248.png\" alt=\"\" class=\"wp-image-7961\"\/><\/figure>\n\n\n\n<p>Criando estrutura de diret\u00f3rios que abrigar\u00e3o o novo CDB:<\/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@oel8 oracle]$ pwd\n\/oracle\n&#x5B;oracle@oel8 oracle]$ mkdir SINAPSE\n&#x5B;oracle@oel8 oracle]$ cd SINAPSE\/\n&#x5B;oracle@oel8 SINAPSE]$ mkdir dados archives fra\n&#x5B;oracle@oel8 SINAPSE]$ ll\ntotal 0\ndrwxr-xr-x. 2 oracle oinstall 6 Mar 28 10:51 archives\ndrwxr-xr-x. 2 oracle oinstall 6 Mar 28 10:51 dados\ndrwxr-xr-x. 2 oracle oinstall 6 Mar 28 10:51 fra\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-249.png\" alt=\"\" class=\"wp-image-7962\"\/><\/figure>\n\n\n\n<p>O novo CDB se chamar\u00e1 Sinapse e n\u00e3o ter\u00e1 nenhum PDB em sua cria\u00e7\u00e3o:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-250.png\" alt=\"\" class=\"wp-image-7963\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-251.png\" alt=\"\" class=\"wp-image-7964\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-252.png\" alt=\"\" class=\"wp-image-7965\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-253.png\" alt=\"\" class=\"wp-image-7966\"\/><\/figure>\n\n\n\n<p>Por algum motivo o DBCA n\u00e3o identificou o listener j\u00e1 existente no ambiente, mas depois eu consigo configurar:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-254.png\" alt=\"\" class=\"wp-image-7968\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-255.png\" alt=\"\" class=\"wp-image-7969\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-256.png\" alt=\"\" class=\"wp-image-7970\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-257.png\" alt=\"\" class=\"wp-image-7971\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-258.png\" alt=\"\" class=\"wp-image-7972\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-259.png\" alt=\"\" class=\"wp-image-7973\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-260.png\" alt=\"\" class=\"wp-image-7974\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-261.png\" alt=\"\" class=\"wp-image-7975\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-262.png\" alt=\"\" class=\"wp-image-7976\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-263.png\" alt=\"\" class=\"wp-image-7977\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-264.png\" alt=\"\" class=\"wp-image-7978\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-265.png\" alt=\"\" class=\"wp-image-7979\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-266.png\" alt=\"\" class=\"wp-image-7980\"\/><\/figure>\n\n\n\n<p>\u00c9 poss\u00edvel ver que a inst\u00e2ncia j\u00e1 est\u00e1 no ar e que o listener j\u00e1 realizou o registro automaticamente:<\/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@oel8 ~]$ ps -ef | grep pmon\noracle    1739     1  0 12:10 ?        00:00:00 ora_pmon_SINAPSE\noracle    3734  6688  0 12:17 pts\/0    00:00:00 grep --color=auto pmon\n&#x5B;oracle@oel8 ~]$\n&#x5B;oracle@oel8 ~]$\n&#x5B;oracle@oel8 ~]$\n&#x5B;oracle@oel8 ~]$ lsnrctl status\n \nLSNRCTL for Linux: Version 18.0.0.0.0 - Production on 28-MAR-2021 12:17:10\n \nCopyright (c) 1991, 2020, Oracle.  All rights reserved.\n \nConnecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))\nSTATUS of the LISTENER\n------------------------\nAlias                     LISTENER\nVersion                   TNSLSNR for Linux: Version 18.0.0.0.0 - Production\nStart Date                28-MAR-2021 10:38:27\nUptime                    0 days 1 hr. 38 min. 42 sec\nTrace Level               off\nSecurity                  ON: Local OS Authentication\nSNMP                      OFF\nListener Log File         \/oracle\/18.0.0\/base\/diag\/tnslsnr\/oel8\/listener\/alert\/log.xml\nListening Endpoints Summary...\n  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oel8.localdomain)(PORT=1521)))\nServices Summary...\nService &quot;SINAPSE.localdomain&quot; has 1 instance(s).\n  Instance &quot;SINAPSE&quot;, status READY, has 1 handler(s) for this service...\nService &quot;SINAPSEXDB.localdomain&quot; has 1 instance(s).\n  Instance &quot;SINAPSE&quot;, status READY, has 1 handler(s) for this service...\nThe command completed successfully\n<\/pre><\/div>\n\n\n<p>Adicionando string de conex\u00e3o no 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@oel8 admin]$ pwd\n\/oracle\/18.0.0\/product\/network\/admin\n&#x5B;oracle@oel8 admin]$ cat tnsnames.ora\nRMANDB =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = oel8.localdomain)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = RMANDB)\n    )\n  )\n \nCORTEX =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = cortex.localdomain)\n    )\n  )\n \nSINAPSE =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = oel8.localdomain)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = sinapse.localdomain)\n    )\n  )\n<\/pre><\/div>\n\n\n<p>Testando conex\u00e3o:<\/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@oel8 admin]$ sqlplus system\/oracle@SINAPSE\n \nSQL*Plus: Release 18.0.0.0.0 - Production on Sun Mar 28 12:24:06 2021\nVersion 18.13.0.0.0\n \nCopyright (c) 1982, 2018, Oracle.  All rights reserved.\n \nLast Successful login time: Sun Mar 28 2021 11:42:41 -03:00\n \nConnected to:\nOracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production\nVersion 18.13.0.0.0\n \nSQL&gt; SHOW CON_NAME CON_ID\n \nCON_NAME\n------------------------------\nCDB$ROOT\n \nCON_ID\n------------------------------\n1\n<\/pre><\/div>\n\n\n<p>Exportando o nodo ORACLE_SID e conectando ao ambiente:<\/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@oel8 admin]$ export ORACLE_SID=SINAPSE\n&#x5B;oracle@oel8 admin]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 18.0.0.0.0 - Production on Sun Mar 28 12:26:34 2021\nVersion 18.13.0.0.0\n \nCopyright (c) 1982, 2018, Oracle.  All rights reserved.\n \n \nConnected to:\nOracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production\nVersion 18.13.0.0.0\n \nSQL&gt; select instance_name,status from v$instance;\n \nINSTANCE_NAME    STATUS\n---------------- ------------\nSINAPSE          OPEN\n<\/pre><\/div>\n\n\n<p>Agora depois de tudo isso podemos pensar no assunto principal do artigo: o procedimento de relocate de PDB. Para facilitar, por conta dos nomes estranhos que estou usando, segue a origem e destino:<\/p>\n\n\n\n<p><strong>CDB DE ORIGEM<\/strong>: TALAMO<br><strong>PDB DE ORIGEM<\/strong>: HIPOFISE2<br><strong>CDB DE DESTINO<\/strong>: SINAPSE<\/p>\n\n\n\n<p>Assim, preciso garantir que o destino possua a string de conex\u00e3o do CDB de origem:<\/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@oel8 admin]$ pwd\n\/oracle\/18.0.0\/product\/network\/admin\n&#x5B;oracle@oel8 admin]$ cat tnsnames.ora\nRMANDB =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = oel8.localdomain)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = RMANDB)\n    )\n  )\n \nCORTEX =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = cortex.localdomain)\n    )\n  )\n \nSINAPSE =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = oel8.localdomain)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = sinapse.localdomain)\n    )\n  )\n \nTALAMO =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.106)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = TALAMO.localdomain)\n    )\n  )\n&#x5B;oracle@oel8 admin]$ tnsping TALAMO\n \nTNS Ping Utility for Linux: Version 18.0.0.0.0 - Production on 28-MAR-2021 12:37:22\n \nCopyright (c) 1997, 2020, Oracle.  All rights reserved.\n \nUsed parameter files:\n\/oracle\/18.0.0\/product\/network\/admin\/sqlnet.ora\n \n \nUsed TNSNAMES adapter to resolve the alias\nAttempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.106)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = TALAMO.localdomain)))\nOK (0 msec)\n<\/pre><\/div>\n\n\n<p>Criando no CDB de destino (SINAPSE), um DB_LINK p\u00fablico que acessa o CDB de origem (TALAMO):<\/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 INSTANCE_NAME,STATUS FROM V$INSTANCE;\n \nINSTANCE_NAME    STATUS\n---------------- ------------\nSINAPSE          OPEN\n \nSQL&gt; CREATE DATABASE LINK BSS CONNECT TO system IDENTIFIED BY oracle USING &#039;TALAMO&#039;;\n \nDatabase link created.\n \nSQL&gt; SELECT * FROM DUAL@BSS;\n \nD\n-\nX\n<\/pre><\/div>\n\n\n<p>Na origem, \u00e9 necess\u00e1rio conceder o privil\u00e9gio ao usu\u00e1rio system, que foi utilizado no db_link:<\/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; GRANT SYSOPER TO SYSTEM CONTAINER=ALL;\n \nGrant succeeded.\n<\/pre><\/div>\n\n\n<p>Para simularmos o relocate, vamos criar um tabela no PDB HIPOFISE2 para depois consult\u00e1-la p\u00f3s opera\u00e7\u00e3o:<\/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@oel8 admin]$ sqlplus system\/oracle@HIPOFISE2\n \nSQL*Plus: Release 18.0.0.0.0 - Production on Sun Mar 28 19:01:02 2021\nVersion 18.13.0.0.0\n \nCopyright (c) 1982, 2018, Oracle.  All rights reserved.\n \nLast Successful login time: Sun Mar 28 2021 12:39:10 -03:00\n \nConnected to:\nOracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production\nVersion 18.13.0.0.0\n \nSQL&gt; CREATE TABLE SYSTEM.BSS ( TEXTO VARCHAR2(100));\n \nTable created.\n \nSQL&gt; INSERT INTO SYSTEM.BSS (TEXTO) VALUES (&#039;TESTE PRE RELOCATE&#039;);\n \n1 row created.\n \nSQL&gt; COMMIT;\n \nCommit complete.\n<\/pre><\/div>\n\n\n<p>Mantendo um processo aberto no PDB de origem:<\/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 SYS_CONTEXT(&#039;USERENV&#039;,&#039;HOST&#039;) CON_ID FROM DUAL;\n \nCON_ID\n--------------------------------------------------------------------------------\noel8.localdomain\n \nSQL&gt; SELECT INSTANCE_NAME FROM V$INSTANCE;\n \nINSTANCE_NAME\n----------------\nTALAMO\n<\/pre><\/div>\n\n\n<p>Conectando no CDB$ROOT de destino e definindo a n\u00edvel de sess\u00e3o o destino dos datafiles que ser\u00e3o movimentados:<\/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@oel8 ~]$ echo $ORACLE_SID\nSINAPSE\n&#x5B;oracle@oel8 ~]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 18.0.0.0.0 - Production on Sun Mar 28 19:07:10 2021\nVersion 18.13.0.0.0\n \nCopyright (c) 1982, 2018, Oracle.  All rights reserved.\n \n \nConnected to:\nOracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production\nVersion 18.13.0.0.0\n \nSQL&gt; ALTER SESSION SET DB_CREATE_FILE_DEST=&#039;\/oracle\/SINAPSE\/dados&#039;;\n \nSession altered.\n<\/pre><\/div>\n\n\n<p>No destino, disparando o comando de relocate, utilizando o par\u00e2metro AVAILABILITY MAX:<\/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; CREATE PLUGGABLE DATABASE HIPOFISE2 FROM HIPOFISE2@BSS RELOCATE AVAILABILITY MAX;\n \nPluggable database created.\n<\/pre><\/div>\n\n\n<p>Realizando mais um insert em nossa tabela de teste, no ambiente de origem:<\/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; INSERT INTO SYSTEM.BSS (TEXTO) VALUES (&#039;TESTE DURANTE RELOCATE&#039;);\n \n1 row created.\n \nSQL&gt; COMMIT;\n \nCommit complete.\n<\/pre><\/div>\n\n\n<p>Avaliando qual \u00e9 o status do novo PDB no CDB de destino. Percebemos que o mesmo est\u00e1 ainda em RELOCATING, ou seja, ainda falta &#8220;oficializarmos&#8221; a opera\u00e7\u00e3o abrindo o PDB:<\/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 PDB_NAME,STATUS FROM CDB_PDBS WHERE PDB_NAME=&#039;HIPOFISE2&#039;;\n \nPDB_NAME\n--------------------------------------------------------------------------------\nSTATUS\n----------\nHIPOFISE2\nRELOCATING\n<\/pre><\/div>\n\n\n<p>J\u00e1 no CDB de origem, o PDB consta como NORMAL, ou seja, ele ainda est\u00e1 operando normalmente:<\/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 PDB_NAME,STATUS FROM CDB_PDBS WHERE PDB_NAME=&#039;HIPOFISE2&#039;;\n \nPDB_NAME\n--------------------------------------------------------------------------------\nSTATUS\n----------\nHIPOFISE2\nNORMAL\n<\/pre><\/div>\n\n\n<p>Realizando novamente uma consulta aleat\u00f3ria na origem:<\/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 SYS_CONTEXT(&#039;USERENV&#039;,&#039;HOST&#039;) CON_ID FROM DUAL;\n \nCON_ID\n--------------------------------------------------------------------------------\noel8.localdomain\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Abrindo o PDB no ambiente de destino. A partir de agora, o relocate pode ser considerado realizado:<\/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; ALTER PLUGGABLE DATABASE HIPOFISE2 OPEN;\n \nWarning: PDB altered with errors.\n<\/pre><\/div>\n\n\n<p>No alert do CDB de destino:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSuccessfully created internal service HIPOFISE2 at open\n****************************************************************\nPost plug operations are now complete.\nPluggable database HIPOFISE2 with pdb id - 3 is now marked as NEW.\n****************************************************************\nPluggable database HIPOFISE2 dictionary check beginning\nPluggable Database HIPOFISE2 Dictionary check complete\nDatabase Characterset for HIPOFISE2 is AL32UTF8\n2021-03-28 19:19:16.649000 -03:00\nViolations: Type: 1, Count: 1\nViolations: Type: 2, Count: 1\n***************************************************************\nWARNING: Pluggable Database HIPOFISE2 with pdb id - 3 is\n         altered with errors or warnings. Please look into\n         PDB_PLUG_IN_VIOLATIONS view for more details.\n***************************************************************\n2021-03-28 19:19:23.648000 -03:00\nOpening pdb with no Resource Manager plan active\nPluggable database HIPOFISE2 opened read write\nCompleted: ALTER PLUGGABLE DATABASE HIPOFISE2 OPEN\n2021-03-28 19:19:39.197000 -03:00\nControl autobackup written to DISK device\nhandle &#039;\/oracle\/SINAPSE\/fra\/SINAPSE\/autobackup\/2021_03_28\/o1_mf_s_1068405576_j6207t45_.bkp&#039;\n<\/pre><\/div>\n\n\n<p>Logo vemos que a natureza no warning foi que, al\u00e9m de um par\u00e2metro de DDL_TIMOUT, o que mais preocupa \u00e9 que o CDB est\u00e1 em 18.13 e o PDB estava na 13.3:<\/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 TIME,CAUSE,MESSAGE,TYPE FROM PDB_PLUG_IN_VIOLATIONS WHERE NAME=&#039;HIPOFISE2&#039;;\n \nTIME\n---------------------------------------------------------------------------\nCAUSE\n----------------------------------------------------------------\nMESSAGE\n--------------------------------------------------------------------------------\nTYPE\n---------\n28-MAR-21 07.19.16.150043 PM\nParameter\nCDB parameter ddl_lock_timeout mismatch: Previous 666 Current 0\nWARNING\n \n \nTIME\n---------------------------------------------------------------------------\nCAUSE\n----------------------------------------------------------------\nMESSAGE\n--------------------------------------------------------------------------------\nTYPE\n---------\n28-MAR-21 07.19.16.435574 PM\nSQL Patch\n&#039;18.13.0.0.0 Release_Update 2012231849&#039; is installed in the CDB but &#039;18.3.0.0.0\nRelease_Update 1806280943&#039; is installed in the PDB\nERROR\n \nTIME\n---------------------------------------------------------------------------\nCAUSE\n----------------------------------------------------------------\nMESSAGE\n--------------------------------------------------------------------------------\nTYPE\n---------\n<\/pre><\/div>\n\n\n<p>Por conta disso, realizo um data patch no PDB em quest\u00e3o:<\/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@oel8 ~]$ cd $ORACLE_HOME\/OPatch\n&#x5B;oracle@oel8 OPatch]$ .\/datapatch -verbose -pdbs HIPOFISE2\nSQL Patching tool version 18.0.0.0.0 Production on Sun Mar 28 19:27:45 2021\nCopyright (c) 2012, 2020, Oracle.  All rights reserved.\n \nLog file for this invocation: \/oracle\/18.0.0\/base\/cfgtoollogs\/sqlpatch\/sqlpatch_10279_2021_03_28_19_27_45\/sqlpatch_invocation.log\n \nConnecting to database...OK\nGathering database info...done\n \nNote:  Datapatch will only apply or rollback SQL fixes for PDBs\n       that are in an open state, no patches will be applied to closed PDBs.\n       Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation\n       (Doc ID 1585822.1)\n \nBootstrapping registry and package to current versions...done\nDetermining current state...done\n \nCurrent state of interim SQL patches:\nInterim patch 27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415)):\n  Binary registry: Installed\n  PDB HIPOFISE2: Applied successfully on 02-MAR-21 06.44.54.948445 AM\n \nCurrent state of release update SQL patches:\n  Binary registry:\n    18.13.0.0.0 Release_Update 2012231849: Installed\n  PDB HIPOFISE2:\n    Applied 18.3.0.0.0 Release_Update 1806280943 successfully on 02-MAR-21 06.44.54.938616 AM\n \nAdding patches to installation queue and performing prereq checks...done\nInstallation queue:\n  For the following PDBs: HIPOFISE2\n    No interim patches need to be rolled back\n    Patch 32204699 (Database Release Update : 18.13.0.0.210119 (32204699)):\n      Apply from 18.3.0.0.0 Release_Update 1806280943 to 18.13.0.0.0 Release_Update 2012231849\n    No interim patches need to be applied\n \nInstalling patches...\nPatch installation complete.  Total patches installed: 1\n \nValidating logfiles...done\nPatch 32204699 apply (pdb HIPOFISE2): SUCCESS\n  logfile: \/oracle\/18.0.0\/base\/cfgtoollogs\/sqlpatch\/32204699\/24011084\/32204699_apply_SINAPSE_HIPOFISE2_2021Mar28_19_28_34.log (no errors)\nSQL Patching tool complete on Sun Mar 28 19:34:04 2021\n<\/pre><\/div>\n\n\n<p>Ap\u00f3s item resolvido, banco reaberto:<\/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; ALTER PLUGGABLE DATABASE HIPOFISE2 OPEN;\nALTER PLUGGABLE DATABASE HIPOFISE2 OPEN\n*\nERROR at line 1:\nORA-65019: pluggable database HIPOFISE2 already open\n \n \nSQL&gt; ALTER PLUGGABLE DATABASE HIPOFISE2 CLOSE;\n \nPluggable database altered.\n \nSQL&gt; ALTER PLUGGABLE DATABASE HIPOFISE2 OPEN;\n \nPluggable database altered.\n<\/pre><\/div>\n\n\n<p>\u00c9 poss\u00edvel notar que nossa sess\u00e3o no PDB de origem caiu. Esse \u00e9 o comportamento esperado, pois \u00e9 no momento da abertura do PDB no destino que o processo finda:<\/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 SYS_CONTEXT(&#039;USERENV&#039;,&#039;HOST&#039;) CON_ID FROM DUAL;\nSELECT SYS_CONTEXT(&#039;USERENV&#039;,&#039;HOST&#039;) CON_ID FROM DUAL\n*\nERROR at line 1:\nORA-03113: end-of-file on communication channel\nProcess ID: 4825\nSession ID: 70 Serial number: 64636\n<\/pre><\/div>\n\n\n<p>No destino, podemos ver o conte\u00fado da nossa tabela de testes:<\/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; ALTER SESSION SET CONTAINER=HIPOFISE2;\n \nSession altered.\n \nSQL&gt; SELECT * FROM SYSTEM.BSS;\n \nTEXTO\n--------------------------------------------------------------------------------\nTESTE PRE RELOCATE\nTESTE DURANTE RELOCATE\n<\/pre><\/div>\n\n\n<p>O mais legal deste recurso vem agora: ao tentar conectar no PDB pela origem, percebemos que o Listener realiza o direcionamento para o PDB de destino:<\/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@oel8 admin]$ sqlplus system\/oracle@HIPOFISE2\n \nSQL*Plus: Release 18.0.0.0.0 - Production on Sun Mar 28 20:21:02 2021\nVersion 18.13.0.0.0\n \nCopyright (c) 1982, 2018, Oracle.  All rights reserved.\n \nLast Successful login time: Sun Mar 28 2021 12:39:10 -03:00\n \nConnected to:\nOracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production\nVersion 18.13.0.0.0\n \nSQL&gt; SELECT SYS_CONTEXT(&#039;USERENV&#039;,&#039;INSTANCE_NAME&#039;) FROM DUAL;\n \nSYS_CONTEXT(&#039;USERENV&#039;,&#039;INSTANCE_NAME&#039;)\n--------------------------------------------------------------------------------\nSINAPSE\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Ao checar o status do PDB no ambiente de origem, vemos que o mesmo j\u00e1 consta como RELOCATED:<\/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 PDB_NAME,STATUS FROM CDB_PDBS WHERE PDB_NAME=&#039;HIPOFISE2&#039;;\n \nPDB_NAME\n--------------------------------------------------------------------------------\nSTATUS\n----------\nHIPOFISE2\nRELOCATED\n<\/pre><\/div>\n\n\n<p>J\u00e1 no ambiente de destino, o PDB aparece como NORMAL:<\/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 PDB_NAME,STATUS FROM CDB_PDBS WHERE PDB_NAME=&#039;HIPOFISE2&#039;;\n \nPDB_NAME\n--------------------------------------------------------------------------------\nSTATUS\n----------\nHIPOFISE2\nNORMAL\n<\/pre><\/div>\n\n\n<p>Esse direcionamento realizado da origem para o destino s\u00f3 \u00e9 poss\u00edvel pelo Listener, que altera o servi\u00e7o para FORWARD SERVER:<\/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@oel8 ~]$ lsnrctl service\n \nLSNRCTL for Linux: Version 18.0.0.0.0 - Production on 29-MAR-2021 04:42:45\n \nCopyright (c) 1991, 2020, Oracle.  All rights reserved.\n \nConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel8.localdomain)(PORT=1521)))\nServices Summary...\nService &quot;TALAMO.localdomain&quot; has 1 instance(s).\n  Instance &quot;TALAMO&quot;, status READY, has 1 handler(s) for this service...\n    Handler(s):\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\n         LOCAL SERVER\nService &quot;TALAMOXDB.localdomain&quot; has 1 instance(s).\n  Instance &quot;TALAMO&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: oel8.localdomain, pid: 2602&gt;\n         (ADDRESS=(PROTOCOL=tcp)(HOST=oel8.localdomain)(PORT=24161))\nService &quot;bdd9ab0055da2c52e0536b00a8c09fce.localdomain&quot; has 1 instance(s).\n  Instance &quot;TALAMO&quot;, status READY, has 2 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: oel8.localdomain, pid: 2602&gt;\n         (ADDRESS=(PROTOCOL=tcp)(HOST=oel8.localdomain)(PORT=24161))\n      &quot;COMMON&quot; established:0 refused:0 state:ready\n         FORWARD SERVER\n         (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel8.localdomain)(PORT=1521)))\nService &quot;hipofise2.localdomain&quot; has 1 instance(s).\n  Instance &quot;TALAMO&quot;, status READY, has 2 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: oel8.localdomain, pid: 2602&gt;\n         (ADDRESS=(PROTOCOL=tcp)(HOST=oel8.localdomain)(PORT=24161))\n      &quot;COMMON&quot; established:0 refused:0 state:ready\n         FORWARD SERVER\n         (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel8.localdomain)(PORT=1521)))\nThe command completed successfully\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>A partir da release 12.2, a Oracle disponibilizou um recurso interessante para n\u00f3s, chamado relocate. Este, consiste basicamente na movimenta\u00e7\u00e3o de um PDB de um CDB para outro CDB, com um downtime m\u00ednimo que ser\u00e1 demonstrado neste artigo. Como eu s\u00f3 possuo um CDB de origem, farei a cria\u00e7\u00e3o do CDB de destino conforme abaixo: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-3213","post","type-post","status-publish","format-standard","hentry","category-multitenant"],"_links":{"self":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/3213","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=3213"}],"version-history":[{"count":1,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/3213\/revisions"}],"predecessor-version":[{"id":9199,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/3213\/revisions\/9199"}],"wp:attachment":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=3213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=3213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=3213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}