Criando oracle data guard 11gR2 em servidor Windows
Autor: Luciano Filho | Publicado: 2012-11-01T12:05:00-07:00


Descrição

Banco Primário = orcl
Banco Stand-by = orcldg


1- No Servidor Standby, criar o arquivo&nbsp;%ORACLE_HOME%\database\initorcldg.ora, com exatamente este parâmetro:

*.db_name = orcl


2 - No Servidor Primário, configurar os seguintes parâmetros:


sql&gt;&nbsp;alter database force logging;
sql&gt;&nbsp;alter system set log_archive_config='dg_config=(orcl,orcldg)';
sql&gt;&nbsp;alter system set log_archive_dest_2='service=orcldg lgwr async noaffirm valid_for=(online_logfiles,primary_role) db_unique_name=orcldg';
sql&gt;&nbsp;alter system set log_archive_dest_state_2=enable;
sql&gt;&nbsp;alter system set log_archive_format='%t_%s_%r.arc' scope=spfile;
sql&gt;&nbsp;alter system set remote_login_passwordfile=exclusive scope=spfile;
sql&gt;&nbsp;alter system set fal_server=orcldg;
sql&gt;&nbsp;alter system set fal_client=orcl;
sql&gt; alter system set standby_file_management=auto;

sql&gt; alter system set dg_broker_start=true;

sql&gt; shutdown immediate;
sql&gt; startup;


3 - Editar no&nbsp;&nbsp;%ORACLE_HOME%\network\admin os arquivos:

No servidor primário, adicionar no listener.ora:


SID_LIST_LISTENER =
&nbsp; (SID_LIST =
&nbsp; &nbsp; (SID_DESC =
&nbsp; &nbsp; &nbsp; (SID_NAME = orcldg)
&nbsp; &nbsp; &nbsp; (ORACLE_HOME = C:\app\user\product\11.2.0\dbhome_1)
&nbsp; &nbsp; &nbsp; (GLOBAL_DBNAME = orcldg_DGMGRL)
&nbsp; &nbsp; &nbsp; (SERVICE_NAME = orcldg)
&nbsp; &nbsp; )
&nbsp; )

No servidor standby, adicionar no listener.ora:



SID_LIST_LISTENER =
&nbsp; (SID_LIST =
&nbsp; &nbsp; (SID_DESC =
&nbsp; &nbsp; &nbsp; (SID_NAME = orcldg)
&nbsp; &nbsp; &nbsp; (ORACLE_HOME = C:\app\user\product\11.2.0\dbhome_1)
&nbsp; &nbsp; &nbsp; (GLOBAL_DBNAME = orcldg)
&nbsp; &nbsp; )
&nbsp; &nbsp; (SID_DESC =
&nbsp; &nbsp; &nbsp; (SID_NAME = orcl)
&nbsp; &nbsp; &nbsp; (ORACLE_HOME = C:\app\user\product\11.2.0\dbhome_1)
&nbsp; &nbsp; &nbsp; (GLOBAL_DBNAME = orcl_DGMGRL)
&nbsp; &nbsp; &nbsp; (SERVICE_NAME = orcl)
&nbsp; &nbsp; )
&nbsp; )


O&nbsp;tnsnames.ora deverá ter as mesmas entradas em ambas as máquinas:


ORCL =
&nbsp; (DESCRIPTION =
&nbsp; &nbsp; (ADDRESS_LIST =
&nbsp; &nbsp; &nbsp; (ADDRESS = (PROTOCOL = TCP)(HOST = 170.10.85.14)(PORT = 1521))
&nbsp; &nbsp; )
&nbsp; &nbsp; (CONNECT_DATA =
&nbsp; &nbsp; &nbsp; (SERVICE_NAME = orcl)
&nbsp; &nbsp; )
&nbsp; )

ORCLDG =
&nbsp; (DESCRIPTION =
&nbsp; &nbsp; (ADDRESS_LIST =
&nbsp; &nbsp; &nbsp; (ADDRESS = (PROTOCOL = TCP)(HOST = 170.10.85.15)(PORT = 1521))
&nbsp; &nbsp; )
&nbsp; &nbsp; (CONNECT_DATA =
&nbsp; &nbsp; &nbsp; (SERVICE_NAME = orcldg) (UR=A)
&nbsp; &nbsp; )
&nbsp; )

Executar o restart do lsnrctl em ambas as máquinas. Pode-se verificar através do tnsping


Copiar o arquivo de senha orapworcl do servidor primário para o servidor standby renomeando para orapworcldg.


4 - Criar um serviço no servidor standby

oradim -new -sid orcldg

SQL&gt; connect sys@orcldg as sysdba
SQL&gt; startup nomount;

5 - No servidor primário criar redo standby logfiles, que dever ter um número maior que o de redo logfiles.

SQL&gt; connect sys@orcl as sysdba
SQL&gt; alter database add standby logfile 'C:\app\user\oradata\orcl\stdby_redo01.log' size 50M;
SQL&gt; alter database add standby logfile&nbsp;'C:\app\user\oradata\orcl\stdby_redo02.log' size 50M;
SQL&gt; alter database add standby logfile&nbsp;'C:\app\user\oradata\orcl\stdby_redo03.log' size 50M;
SQL&gt; alter database add standby logfile&nbsp;'C:\app\user\oradata\orcl\stdby_redo04.log' size 50M;

6 - Criar a estrutura de diretório no servidor standby conforme o servidor primário, no meu caso, foram criados:


C:\app\user\oradata\orcl
C:\app\user\fast_recovery_area\orcl
C:\app\user\admin\orcl\adump


7 - Realizar o RMAN Duplicate

RMAN&gt; connect target sys@orcl

RMAN&gt; connect auxiliary sys@orcldg

RMAN&gt;&nbsp;run{
allocate channel prmy1 type disk;
allocate auxiliary channel stby1 type disk;
duplicate target database for standby from active database
dorecover
spfile
set db_unique_name='orcldg'
set log_archive_dest_2='service=orcl lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl'
set log_archive_dest_state_2='enable'
set fal_server='orcl'
set fal_client='orcldg'
set log_archive_config='dg_config=(orcl,orcldg)'
set dg_broker_start='true'
set standby_file_management='auto'
nofilenamecheck;
}

SQL&gt; connect sys@orcldg as sysdba;
SQL&gt; recover managed standby database disconnect;
SQL&gt; recover managed standby database cancel;
SQL&gt; alter database open read only;
SQL&gt; recover managed standby database using current logfile disconnect;

8 - Configurar o dataguard broker

DGMGRL&gt; connect sys@orcl
DGMGRL&gt; create configuration 'standby_config' as
&nbsp; &nbsp; &gt; primary database is 'orcl''
&nbsp; &nbsp; &gt; connect identifier is 'orcl'';

DGMGRL&gt; show configuration;
DGMGRL&gt; add database 'orcldg'' as
&nbsp; &nbsp; &gt; connect identifier is orcldg;
DGMGRL&gt; enable configuration;
DGMGRL&gt; enable database orcldg;


Pronto, tarefa finalizada!