{"id":2375,"date":"2021-03-05T08:42:43","date_gmt":"2021-03-05T08:42:43","guid":{"rendered":"https:\/\/swiv.com.br\/preparing-the-primary-database-for-oracle-data-guard\/"},"modified":"2026-05-27T20:02:52","modified_gmt":"2026-05-27T19:02:52","slug":"preparing-the-primary-database-for-oracle-data-guard","status":"publish","type":"post","link":"https:\/\/swiv.com.br\/index.php\/2021\/03\/05\/preparing-the-primary-database-for-oracle-data-guard\/","title":{"rendered":"Preparing the Primary Database for Oracle Data Guard"},"content":{"rendered":"<p>Como pr\u00e9-requisito, \u00e9 necess\u00e1rio que o banco primary esteja em archiving mode. Caso voc\u00ea precise fazer isso, pode seguir este artigo <a href=\"https:\/\/swiv.com.br\/changing-the-oracle-database-archiving-mode\/\" target=\"\\&quot;_blank\\&quot;\" rel=\"\\&quot;noreferrer noopener\" noopener=\"\">AQUI<\/a>.<\/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@fornix1 ~]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 5 04:52:55 2021\nVersion 19.3.0.0.0\n \nCopyright (c) 1982, 2019, Oracle.  All rights reserved.\n \n \nConnected to:\nOracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production\nVersion 19.3.0.0.0\n \nSQL&gt; SELECT LOG_MODE FROM V$DATABASE ;\n \nLOG_MODE\n------------\nARCHIVELOG\n \nSQL&gt; SHO PARAMETER LOG_ARCHIVE_DEST_1\n \nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\nlog_archive_dest_1                   string      LOCATION=+DG_RECO\nlog_archive_dest_10                  string\nlog_archive_dest_11                  string\nlog_archive_dest_12                  string\nlog_archive_dest_13                  string\nlog_archive_dest_14                  string\nlog_archive_dest_15                  string\nlog_archive_dest_16                  string\nlog_archive_dest_17                  string\nlog_archive_dest_18                  string\nlog_archive_dest_19                  string\nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Habilitando o FORCE LOGGIN:<\/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 FORCE_LOGGING FROM V$DATABASE;\n \nFORCE_LOGGING\n---------------------------------------\nNO\n \nSQL&gt; ALTER DATABASE FORCE LOGGING;\n \nDatabase altered.\n \nSQL&gt; SELECT FORCE_LOGGING FROM V$DATABASE;\n \nFORCE_LOGGING\n---------------------------------------\nYES\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Configurando os Standby Redo Logs. Lembrando que a sua quantidade ficaria como (3+1)*1=4:<\/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 GROUP#, BYTES\/1024\/1024 MB FROM V$LOG;\n \n    GROUP#         MB\n---------- ----------\n         1        200\n         2        200\n         3        200\n \nSQL&gt; SELECT THREAD#, INSTANCE FROM V$THREAD ;\n \n   THREAD#\n----------\nINSTANCE\n--------------------------------------------------------------------------------\n         1\ncortex\n \n \nSQL&gt; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 &#039;+DG_FRA&#039; SIZE 200M ;\n \nDatabase altered.\n \nSQL&gt; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 &#039;+DG_FRA&#039; SIZE 200M ;\n \nDatabase altered.\n \nSQL&gt; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 &#039;+DG_FRA&#039; SIZE 200M ;\n \nDatabase altered.\n \nSQL&gt; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 &#039;+DG_FRA&#039; SIZE 200M ;\n \nDatabase altered.\n \nSQL&gt; SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;\n \n    GROUP#    THREAD#  SEQUENCE# ARC STATUS\n---------- ---------- ---------- --- ----------\n         4          1          0 YES UNASSIGNED\n         5          1          0 YES UNASSIGNED\n         6          1          0 YES UNASSIGNED\n         7          1          0 YES UNASSIGNED\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Alterando os par\u00e2metros do primary:<\/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; show parameter DB_UNIQUE_NAME\n \nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\ndb_unique_name                       string      cortex\nSQL&gt; ALTER SYSTEM SET LOG_ARCHIVE_CONFIG=&#039;DG_CONFIG=(cortex,cortexDR)&#039; scope=BOTH;\n \nSystem altered.\n \nSQL&gt; ALTER SYSTEM SET LOG_ARCHIVE_DEST_2= &#039;SERVICE=cortexDR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=cortexDR&#039; scope=BOTH;\n \nSystem altered.\n \nSQL&gt; ALTER SYSTEM SET ARCHIVE_LAG_TARGET=1800 scope=BOTH;\n \nSystem altered.\n \nSQL&gt; show parameter REMOTE_LOGIN_PASSWORDFILE\n \nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\nremote_login_passwordfile            string      EXCLUSIVE\nSQL&gt; show parameter FAL_SERVER ;\n \nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\nfal_server                           string\nSQL&gt; alter system set FAL_SERVER =&#039;cortexDR&#039; scope=BOTH;\n \nSystem altered.\n \nSQL&gt; show parameter STANDBY_FILE_MANAGEMENT\n \nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\nstandby_file_management              string      MANUAL\nSQL&gt; alter system set STANDBY_FILE_MANAGEMENT=&#039;AUTO&#039; scope=BOTH;\n \nSystem altered.\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Coletando a lista de diret\u00f3rios que dever\u00e3o existir no ambiente Standby:<\/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, VALUE FROM V$PARAMETER WHERE upper(VALUE) LIKE upper(&#039;%\/cortex\/%&#039;);\n \nNAME\n--------------------------------------------------------------------------------\nVALUE\n--------------------------------------------------------------------------------\nspfile\n+DG_DATA\/CORTEX\/PARAMETERFILE\/spfile.265.1039034301\n \ncontrol_files\n+DG_DATA\/CORTEX\/CONTROLFILE\/current.260.1039033623, +DG_FRA\/CORTEX\/CONTROLFILE\/c\nurrent.256.1039033625\n \ncore_dump_dest\n\/oracle\/19.3.0\/base\/diag\/rdbms\/cortex\/cortex\/cdump\n \nNAME\n--------------------------------------------------------------------------------\nVALUE\n--------------------------------------------------------------------------------\n \naudit_file_dest\n\/oracle\/19.3.0\/base\/admin\/cortex\/adump\n \n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>De forma opcional, podemos habilitar o recurso de Flashback Database (o que seria recomendado):<\/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 system set DB_FLASHBACK_RETENTION_TARGET =2880 scope=BOTH;\n \nSystem altered.\n \nSQL&gt; ALTER DATABASE FLASHBACK ON;\n \nDatabase altered.\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Ajustando par\u00e2metro do controlfile:<\/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; show parameter CONTROL_FILE_RECORD_KEEP_TIME;\n \nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\ncontrol_file_record_keep_time        integer     7\nSQL&gt; alter system set CONTROL_FILE_RECORD_KEEP_TIME=30 scope=BOTH;\n \nSystem altered.\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Validar se seu ambiente j\u00e1 possui um password file:<\/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@fornix1 ~]$ cd $ORACLE_HOME\/dbs\n&#x5B;oracle@fornix1 dbs]$ ls -lthr\ntotal 11M\n-rw-r--r--. 1 oracle oinstall 3.1K May 14  2015 init.ora\n-rw-r-----. 1 oracle asmadmin   24 Apr 29  2020 lkCORTEX\n-rw-r-----. 1 oracle oinstall 2.0K Feb 26 05:43 orapwcortex\n-rw-rw----. 1 oracle asmadmin 1.6K Mar  5 04:51 hc_cortex.dat\n-rw-r-----. 1 oracle asmadmin  11M Mar  5 05:11 snapcf_cortex.f\n&#x5B;oracle@fornix1 dbs]$\n<\/pre><\/div>\n\n\n<p>Ajustando o arquivo \/etc\/hosts para que o ambiente primary possa se comunicar com o standby:<\/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@fornix1 dbs]$ cat \/etc\/hosts\n127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4\n#::1         localhost localhost.localdomain localhost6 localhost6.localdomain6\n192.168.0.109 fornix1.localdomain fornix1\n192.168.0.110 fornix2.localdomain fornix2\n&#x5B;oracle@fornix1 dbs]$ ping fornix2\nPING fornix2.localdomain (192.168.0.110) 56(84) bytes of data.\n64 bytes from fornix2.localdomain (192.168.0.110): icmp_seq=1 ttl=64 time=2.33 ms\n64 bytes from fornix2.localdomain (192.168.0.110): icmp_seq=2 ttl=64 time=1.17 ms\n64 bytes from fornix2.localdomain (192.168.0.110): icmp_seq=3 ttl=64 time=1.39 ms\n<\/pre><\/div>\n\n\n<p>Ajustando 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@fornix1 admin]$ cat tnsnames.ora\n# tnsnames.ora Network Configuration File: \/oracle\/19.3.0\/product\/network\/admin\/tnsnames.ora\n# Generated by Oracle configuration tools.\n \nCORTEX =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = fornix1.localdomain)(PORT = 1521))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = cortex.localdomain)\n    )\n  )\n \nLISTENER_LISTENER =\n  (ADDRESS = (PROTOCOL = TCP)(HOST = fornix1.localdomain)(PORT = 1521))\n \n \nCORTEXDR =\n  (DESCRIPTION =\n    (ADDRESS = (PROTOCOL = TCP)(HOST = fornix2.localdomain)(PORT = 1522))\n    (CONNECT_DATA =\n      (SERVER = DEDICATED)\n      (SERVICE_NAME = cortexDR.localdomain)\n    )(UR=A)\n  )\n \n \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&#x5B;oracle@fornix1 admin]$\n<\/pre><\/div>\n\n\n<p>Teste de tnsping:<\/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@fornix1 admin]$ tnsping CORTEX\n \nTNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 05-MAR-2021 05:31:42\n \nCopyright (c) 1997, 2019, Oracle.  All rights reserved.\n \nUsed parameter files:\n\/oracle\/19.3.0\/product\/network\/admin\/sqlnet.ora\n \n \nUsed TNSNAMES adapter to resolve the alias\nAttempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = fornix1.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = cortex.localdomain)))\nOK (10 msec)\n&#x5B;oracle@fornix1 admin]$ tnsping CORTEXDR\n \nTNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 06-MAR-2021 11:45:29\n \nCopyright (c) 1997, 2019, Oracle.  All rights reserved.\n \nUsed parameter files:\n\/oracle\/19.3.0\/product\/network\/admin\/sqlnet.ora\n \n \nUsed TNSNAMES adapter to resolve the alias\nAttempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = fornix2.localdomain)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = cortexDR.localdomain))(UR=A))\nOK (10 msec)\n&#x5B;oracle@fornix1 admin]$\n<\/pre><\/div>\n\n\n<p>Validando arquivo sqlnet.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@fornix1 admin]$ cat sqlnet.ora\n# sqlnet.ora Network Configuration File: \/oracle\/19.3.0\/product\/network\/admin\/sqlnet.ora\n# Generated by Oracle configuration tools.\n \nNAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)\n \n&#x5B;oracle@fornix1 admin]$\n<\/pre><\/div>\n\n\n<p>N\u00e3o \u00e9 dif\u00edcil se deparar com o erro abaixo, ao tentar fazer o Duplicate do banco. E para isso, j\u00e1 vou fazer a c\u00f3pia do SPFILE para o local onde o RMAN pensa que est\u00e1 hospedado:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nRMAN-03009: failure of backup command on prmy2 channel at 05\/03\/2021 05:38:08 \nORA-19505: failed to identify file &quot;+DG_DATA\/CORTEX\/spfilecortex.ora&quot; \nORA-15173: entry &#039;spfilecortex.ora&#039; does not exist in directory &#039;CORTEX&#039;\n<\/pre><\/div>\n\n\n<p>Fazendo c\u00f3pia do SPFILE:<\/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@fornix1 admin]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 5 05:38:59 2021\nVersion 19.3.0.0.0\n \nCopyright (c) 1982, 2019, Oracle.  All rights reserved.\n \n \nConnected to:\nOracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production\nVersion 19.3.0.0.0\n \nSQL&gt; sho parameter spfile\n \nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\nspfile                               string      +DG_DATA\/CORTEX\/PARAMETERFILE\/\n                                                 spfile.265.1039034301\nSQL&gt; exit\nDisconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production\nVersion 19.3.0.0.0\n&#x5B;oracle@fornix1 admin]$ su - grid\nPassword:\nLast login: Fri Mar  5 05:35:16 -03 2021 on pts\/0\n&#x5B;grid@fornix1 ~]$ asmcmd\nASMCMD&gt; cd DG_DATA\/CORTEX\/PARAMETERFILE\/\nASMCMD&gt; cp spfile.265.1039034301 +DG_DATA\/CORTEX\/spfilecortex.ora;\ncopying +DG_DATA\/CORTEX\/PARAMETERFILE\/spfile.265.1039034301 -&gt; +DG_DATA\/CORTEX\/spfilecortex.ora\nASMCMD&gt;\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>Como pr\u00e9-requisito, \u00e9 necess\u00e1rio que o banco primary esteja em archiving mode. Caso voc\u00ea precise fazer isso, pode seguir este artigo AQUI. Habilitando o FORCE LOGGIN: Configurando os Standby Redo Logs. Lembrando que a sua quantidade ficaria como (3+1)*1=4: Alterando os par\u00e2metros do primary: Coletando a lista de diret\u00f3rios que dever\u00e3o existir no ambiente Standby: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2375","post","type-post","status-publish","format-standard","hentry","category-high-availability"],"_links":{"self":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/2375","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=2375"}],"version-history":[{"count":1,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/2375\/revisions"}],"predecessor-version":[{"id":9248,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/2375\/revisions\/9248"}],"wp:attachment":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=2375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=2375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=2375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}