Adicionando e removendo redologs no banco de dados Standby
Autor: ORACLE Place | Publicado: 2014-05-01T12:25:00-07:00



Adicionando "redo
logs" no banco de dados Standby



Adicionar "redo logs"
no banco de dados não afeta o banco de dados Standby. Porém durante transição
alguns problemas de desempenho podem ocorrer. Logo,&nbsp; sempre que um arquivo de "redo log"
for adicionado ou removido do banco de dados primário, o mesmo deve ser
executado manualmente no banco de dados Standby. Abaixo o procedimento.



1. Verificar os membros no banco de dados Standby.

SQL&gt; select member from v$logfile;

MEMBER
------------------------------
+DATA/test/group/group_3.264.3

+DATA/test/group/group_2.264.3

+DATA/test/group/group_1.264.3


2. Cancelar o processo de "recover" do banco de dados
Standby.

SQL&gt; alter database recover managed
standby database cancel;


Database altered.

3. Verificar o parâmetro "standby_file_management" e
configurá-lo para MANUAL.

SQL&gt; show parameter standby_file

NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALUE
------------------------------------ ----------- ------
standby_file_management&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AUTO

<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

SQL&gt; alter system set
standby_file_management=manual scope=both;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

System altered.

SQL&gt; show parameter standby_file

NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALUE
------------------------------------ ----------- ------
standby_file_management&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MANUAL

<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

4. Uma vez alterado o parâmetro, pode-se adicionar os "redo logs"
no banco de dados Standby.


SQL&gt; alter database add logfile group 4
'+DATA' size 100M;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

SQL&gt; alter database add logfile group 5 '+DATA' size 100M;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

SQL&gt; alter database add logfile group 6 '+DATA' size 100M;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

SQL&gt; alter database add standby logfile group 7 '+DATA' size 100M;


Database altered.

SQL&gt; alter database add standby logfile
group 8 '+DATA' size 100M;


Database altered.

SQL&gt; alter database add standby logfile group 9 '+DATA' size 100M;


Database altered.

SQL&gt; alter database add standby logfile group 10 '+DATA' size 100M;


Database altered.

<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

5. Verificação dos "redo logs". 

SQL&gt; col members for 999999999
SQL&gt; set lines 120 pages 1000


SQL&gt; select group#, members, status from v$log;

&nbsp;&nbsp;&nbsp; GROUP#&nbsp;&nbsp;&nbsp; MEMBERS STATUS
---------- ---------- ----------------
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 CLEARING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 CLEARING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 CLEARING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 UNUSED
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 CLEARING_CURRENT
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 UNUSED

6 rows selected.



SQL&gt; select member from v$logfile order by 1 desc;

MEMBER
-------------------------------
+DATA/test/group/group_6.264.3

+DATA/test/group/group_5.264.3

+DATA/test/group/group_4.264.3

+DATA/test/group/group_3.264.3

+DATA/test/group/group_2.264.3

+DATA/test/group/group_1.264.3


6 rows selected.
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

6. Verificação dos standby "redo logs". 
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

SQL&gt; set lines 300

SQL&gt; col member format a50



SQL&gt; select substr(a.MEMBER,1,50)
MEMBER 

&nbsp;&nbsp; from
v$logfile a, v$standby_log b

&nbsp; where
a.group# = b.group#

&nbsp; order
by 1;

MEMBER
-------------------------------
+DATA/test/group/group_7.264.3

+DATA/test/group/group_8.264.3

+DATA/test/group/group_9.264.3

+DATA/test/group/group_10.264.3



4 rows selected.
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->


7. Voltar o parâmetro "standby_file_management" para AUTO.

SQL&gt; alter system set
standby_file_management=auto scope=both;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

System altered.

8. Ativar o processo de "recover" no banco de dados
Standby.

SQL&gt; alter database recover managed
standby database disconnect from session;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->



Removendo "redo logs" no banco de dados Standby 

1. Cancelar o processo de "recover".

SQL&gt; alter database recover managed
standby database cancel;


Database altered.

2. Verificar o parâmetro "standby_file_management" e configurá-lo
para MANUAL.

SQL&gt; show parameter standby_file

NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALUE
------------------------------------ ----------- ------
standby_file_management&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AUTO

<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

SQL&gt; alter system set standby_file_management=manual
scope=both;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

System altered.

SQL&gt; show parameter standby_file

NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALUE
------------------------------------ ----------- ------
standby_file_management&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MANUAL

3. Verificar o "status" dos
arquivos de "redo logs" antes de removê-lo. 

SQL&gt; select group#, status from v$log;

&nbsp;&nbsp;&nbsp; GROUP# STATUS
---------- ----------------

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 CLEARING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 CLEARING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3 CLEARING
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 UNUSED

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5&nbsp;CLEARING_CURRENT
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6 UNUSED

6 rows selected.
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

NOTA: Se os
"status" dos "redo logs" estiverem em "CLEARING",
"CURRENT_CLEARING" ou "ACTIVE" indica que os arquivos estão
sincronizados com o banco de dados primário. Caso os "status" estejam
diferentes desses, um erro poderá ocorrer, durante a execução do procedimento
de remoção. 



SQL&gt; alter database drop logfile group
1;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

alter database drop logfile group 1
ERROR at line 1:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
ORA-01156: recovery in progress may need access to files&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
3.1. Para sincronizar os "redo logs"
deve-se executar os comandos abaixo.


SQL&gt; alter database clear logfile group
1;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

SQL&gt; alter database clear logfile group 2;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

SQL&gt; alter database clear logfile group 3;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

3.2. Verificar os "status" dos "redo logs"
novamente.


SQL&gt; select group#,status from v$log;

&nbsp;&nbsp;&nbsp; GROUP# STATUS
---------- ----------------
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 UNUSED
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 UNUSED
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3 UNUSED
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 UNUSED

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5 CLEARING_CURRENT
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6 UNUSED

6 rows selected.

4. Depois de sincronizados, pode-se remover os "redo logs".


SQL&gt;
alter database drop logfile group 1;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

SQL&gt; alter database drop logfile group 2;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

SQL&gt; alter database drop logfile group 3;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.

5. Verificar os "status" dos "redologs".

SQL&gt; select group#, members, status
from v$log;

&nbsp;&nbsp;&nbsp; GROUP#&nbsp;&nbsp;&nbsp; MEMBERS STATUS
---------- ---------- ----------------
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 UNUSED
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 CLEARING_CURRENT
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 UNUSED

6. Verificar o parâmetro "standby_file_management"
e alterá-lo para AUTO.

SQL&gt; alter system set
standby_file_management=auto scope=both;


System altered.

<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

7. Ativar o processo de "recover".

SQL&gt; alter database recover managed
standby database disconnect from session;
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

Database altered.





Referências: Oracle®
Database Administrator´s Guide 11gR2 (11.2)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Oracle® Data Guard Concepts and
Administration 11gR2
(11.2)







MSc.
Rubens Oliveira

DBA Oracle Consultor

olivert.dba@consultant.com