Você está na página 1de 10

Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 1 of 10

Broker, Dataguard e Real-Time Apply - 10g


Este é o complemento do artigo anterior, onde discutimos como montar um Data Guard usando o RMAN. A seguir,
farei da mesma forma, ou seja, não haverá explicações específicas para os comandos, já que o melhor source para
isso é o próprio manual.

Então começamos com as instâncias criadas no artigo anterior (n1dg e n2dg), a princípio definidas como n1dg = nó
primário e n2dg = nó standby físico. Vamos então aos copies e pastes.

Garantia que não havia nenhuma instance viva.

[marcio@anakin ~]$ ps -ef | grep pmon_


marcio 6175 6044 0 00:07 pts/1 00:00:00 grep pmon_
[marcio@anakin ~]$
[marcio@anakin ~]$
[marcio@anakin ~]$ su - oracle
Password:
[oracle@anakin ~]$
[oracle@anakin ~]$
[oracle@anakin ~]$ cd /oracle/admin/
[oracle@anakin admin]$ ll -tr
total 20
drwxr-x--- 6 oracle dba 4096 Feb 15 14:22 +ASM
drwxr-x--- 8 oracle dba 4096 Feb 15 14:28 lx10g
drwxr-xr-x 7 ora92 dba 4096 Mar 27 16:48 lx92
drwxr-x--- 9 oracle dba 4096 Jun 3 23:06 n1dg
drwxr-xr-x 9 oracle dba 4096 Jun 3 23:58 n2dg
[oracle@anakin admin]$

Levantando nó primário.

[oracle@anakin admin]$ export ORACLE_SID=n1dg


[oracle@anakin admin]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:08:17 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to an idle instance.
idle> startup
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1263200 bytes
Variable Size 205523360 bytes
Database Buffers 394264576 bytes
Redo Buffers 7122944 bytes
Database mounted.
Database opened.
idle>

Checando os parâmetros pré-configurados no artigo anterior.

idle> show parameter archive


NAME TYPE VALUE
------------------------------------ ----------- -----------------------------
archive_lag_target integer 0
log_archive_config string DG_CONFIG=(n1, n2)
log_archive_dest string
log_archive_dest_1 string LOCATION=/backup/n1/arch
log_archive_dest_10 string
log_archive_dest_2 string
log_archive_dest_3 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string
log_archive_dest_8 string
log_archive_dest_9 string
log_archive_dest_state_1 string enable
log_archive_dest_state_10 string enable
log_archive_dest_state_2 string enable
log_archive_dest_state_3 string enable
log_archive_dest_state_4 string enable
log_archive_dest_state_5 string enable
log_archive_dest_state_6 string enable
log_archive_dest_state_7 string enable
log_archive_dest_state_8 string enable
log_archive_dest_state_9 string enable
log_archive_duplex_dest string
log_archive_format string %t_%s_%r.dbf
log_archive_local_first boolean TRUE
log_archive_max_processes integer 2
log_archive_min_succeed_dest integer 1
log_archive_start boolean FALSE
log_archive_trace integer 0
remote_archive_enable string true
standby_archive_dest string /backup/n1/arch
idle> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------
db_name string N1DG
idle> show parameter db_unique_name
NAME TYPE VALUE

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010
Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 2 of 10

------------------------------------ ----------- ---------------------------


db_unique_name string n1
idle> show parameter fal
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------
fal_client string N1
fal_server string N2
idle>

No nó primário, setar o DEST_1 com o novo parâmetro VALID_FOR Dataguard na versão 10g juntamente com o
db_unique_name.

idle> alter system set LOG_ARCHIVE_DEST_1='LOCATION=/backup/n1/arch


2 VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
3 DB_UNIQUE_NAME=n1'
4 /
System altered.

Da mesma forma, porém desta vez vamos configurar o DEST_2, onde será entregue o archive para o standby. Nessa
configuração, é importante para aplicação via archives, porém não obrigatório para nosso exemplo, porque faremos
real-time apply, ou seja, poderíamos deixar de configurar o DEST_2 e criar somente os standby logfiles. Essa
configuração é importante em emergências de rede, etc.

idle> alter system set LOG_ARCHIVE_DEST_2='SERVICE=n2


2 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
3 DB_UNIQUE_NAME=n2';
4 /
System altered.
idle> show parameter LOG_ARCHIVE_MAX_PROCESSES
NAME TYPE VALUE
------------------------------------ ----------- --------------------
log_archive_max_processes integer 2
idle> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@anakin admin]$
[oracle@anakin admin]$
[oracle@anakin admin]$ echo $ORACLE_SID
n1dg
[oracle@anakin admin]$ export ORACLE_SID=n2dg

Passo 2: Configurar o standby (n2dg) - Não esquecer que a parte de rede foi previamente definida no artigo anterior.

[oracle@anakin admin]$ sqlplus / as sysdba


SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:17:21 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to an idle instance.
idle> startup mount
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/oracle/10g/dbs/initn2dg.ora'
idle> exit
Disconnected

Acho interessante deixar os problemas que tive durante a configuração. Por exemplo, o erro acima aconteceu porque
eu esqueci de criar o spfile no artigo anterior. Então vamos levantar a instância com o pfile já usado anteriormente e
a partir dele criar o spfile.

[oracle@anakin admin]$ cd n2dg/scripts/


[oracle@anakin scripts]$ ll -tr
total 8
-rw-r--r-- 1 oracle dba 482 Jun 3 23:57 n2dg.sh
-rw-r--r-- 1 oracle dba 646 Jun 4 00:04 init.ora
[oracle@anakin scripts]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:17:43 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to an idle instance.
idle> startup mount pfile=./init.ora
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1263200 bytes
Variable Size 167774624 bytes
Database Buffers 432013312 bytes
Redo Buffers 7122944 bytes
Database mounted.
idle> !pwd
/oracle/admin/n2dg/scripts
idle> create spfile from pfile='/oracle/admin/n2dg/scripts/init.ora';
File created.
idle> startup mount force
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1263200 bytes
Variable Size 167774624 bytes
Database Buffers 432013312 bytes
Redo Buffers 7122944 bytes
Database mounted.
idle> show parameter db_name

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010
Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 3 of 10

NAME TYPE VALUE


------------------------------------ ----------- -------------------------
db_name string n1dg
idle> show parameter db_unique_name
NAME TYPE VALUE
------------------------------------ ----------- -------------------------
db_unique_name string n2

Hora das modificações do standby

idle> show parameter STANDBY_ARCHIVE_DEST


NAME TYPE VALUE
------------------------------------ ----------- -------------------------
standby_archive_dest string ?/dbs/arch
idle> alter system set STANDBY_ARCHIVE_DEST='/backup/n2/arch';
System altered.
idle> alter system set log_archive_config='DG_CONFIG=(n1, n2)';
System altered.
idle> alter system set LOG_ARCHIVE_DEST_1='LOCATION=/backup/n2/arch
2 VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
3 DB_UNIQUE_NAME=n2'
4 /
System altered.
idle> alter system set LOG_ARCHIVE_DEST_2='SERVICE=n1
2 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
3 DB_UNIQUE_NAME=n1'
4 /
System altered.

Server do standby é o nó principal (N1) e client é o (N2) o inverso do nó primário.

idle> alter system set fal_server=n1;


System altered.
idle> alter system set fal_client=n2;
System altered.
idle> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
------------- ------------- ------------- ------------- ------------- --- ---------------- ------------- ---------
1 1 2 52428800 1 NO CURRENT 485605 03-JUN-07
3 1 1 52428800 1 YES INACTIVE 456954 03-JUN-07
2 1 0 52428800 1 YES UNUSED 0
3 rows selected.

Os próximos passos são a chave para o Real-Time Apply, porque faremos a aplicação das modificações através dos
standby lofiles. Há necessidade criar tanto no physical standby como no primário.

idle> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/backup/n2/n2dg/srl01.log') SIZE 50M;
Database altered.
idle> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/backup/n2/n2dg/srl02.log') SIZE 50M;
Database altered.
idle> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/backup/n2/n2dg/srl03.log') SIZE 50M;
Database altered.
idle> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
Database altered.
idle> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
------------- ------------- ------------- ------------- ------------- --- ---------------- ------------- ---------
1 1 0 52428800 1 NO CURRENT 485605 03-JUN-07
3 1 0 52428800 1 YES UNUSED 456954 03-JUN-07
2 1 0 52428800 1 YES UNUSED 0
3 rows selected.
idle> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@anakin scripts]$ export ORACLE_SID=n1dg
[oracle@anakin scripts]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:28:15 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
sys:N1DG> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/backup/n1/n1dg/srl01.log') SIZE 50M;
Database altered.
sys:N1DG> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/backup/n1/n1dg/srl02.log') SIZE 50M;
Database altered.
sys:N1DG> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/backup/n1/n1dg/srl03.log') SIZE 50M;
Database altered.
sys:N1DG> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME
------------- ------------- ------------- ------------- ------------- --- ---------------- ------------- -------------------
1 1 5 52428800 1 YES INACTIVE 528846 05/06/2007 00:00:55
3 1 7 52428800 1 NO CURRENT 602414 12/06/2007 00:08:28
2 1 6 52428800 1 YES INACTIVE 574349 09/06/2007 19:53:50
3 rows selected.
sys:N1DG> alter system switch logfile;
System altered.
sys:N1DG> alter system switch logfile;
System altered.

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010
Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 4 of 10

sys:N1DG> select * from v$log;


GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME
------------- ------------- ------------- ------------- ------------- --- ---------------- ------------- -------------------
1 1 8 52428800 1 NO ACTIVE 604660 12/06/2007 00:29:30
3 1 7 52428800 1 NO ACTIVE 602414 12/06/2007 00:08:28
2 1 9 52428800 1 NO CURRENT 604662 12/06/2007 00:29:32
3 rows selected.
sys:N1DG> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@anakin scripts]$ export ORACLE_SID=n2dg
[oracle@anakin scripts]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:29:55 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
idle> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME
------------- ------------- ------------- ------------- ------------- --- ---------------- ------------- -------------------
1 1 0 52428800 1 NO CURRENT 485605 03/06/2007 23:23:05
3 1 0 52428800 1 YES UNUSED 456954 03/06/2007 23:10:55
2 1 0 52428800 1 YES UNUSED 0
3 rows selected.
idle> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options

Como notado acima, nada de aplicação de redos ainda. Agora entra a parte da configuração do Data Guard Broker
através do parâmetro DG_BROKER_START, não esquecer de mudar para TRUE em todos os nós que serão controlados
pelo BROKER. (Obs: Depois que voce conhece o broker, nunca mais vai achar difícil fazer switchover, failover ou
qualquer outra manutenção no seu dataguard).

[oracle@anakin scripts]$ export ORACLE_SID=n1dg


[oracle@anakin scripts]$
[oracle@anakin scripts]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:30:24 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
sys:N1DG> show parameter dg
NAME TYPE VALUE
------------------------------------ ----------- --------------------------------------------------
dg_broker_config_file1 string /oracle/10g/dbs/dr1n1.dat
dg_broker_config_file2 string /oracle/10g/dbs/dr2n1.dat
dg_broker_start boolean FALSE
sys:N1DG> alter system set dg_broker_start=true;
System altered.
sys:N1DG> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@anakin scripts]$ export ORACLE_SID=n2dg
[oracle@anakin scripts]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:30:48 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
idle> alter system set dg_broker_start=true;
System altered.
idle> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@anakin scripts]$ export ORACLE_SID=n1dg
[oracle@anakin scripts]$

Ok, agora que os serviços do Broker estão no ar, vamos ao client para criar a configuração do dataguard, note que o
seu standby já está montado, portanto o broker irá herdar a maioria de suas configurações quando o database for
adicionado. Neste ponto não esqueça de ter criado os arquivos de senha e colocado a mesma senha do sys para todos
os nós, isso facilita na manutenção, porque o broker se conecta nos nós e faz shutdown e startup quando necessário.

[oracle@anakin scripts]$ dgmgrl


DGMGRL for Linux: Version 10.2.0.3.0 - Production
Copyright (c) 2000, 2005, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle
Connected.
DGMGRL>
DGMGRL> create configuration mportes_dg as
> primary database is n1
> connect identifier is n1;
Configuration "mportes_dg" created with primary database "n1"
DGMGRL> ADD DATABASE n2 AS CONNECT IDENTIFIER IS n2 MAINTAINED AS PHYSICAL;
Error: ORA-16796: one or more properties could not be imported from the database
Failed.
DGMGRL> exit

Importante o erro acima, nesse ponto vejo qual foi o problema consultando o código de erro online.

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010
Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 5 of 10

[oracle@anakin scripts]$ oerr ora 16796


16796, 0000, "one or more properties could not be imported from the database"
// *Cause: The broker was unable to import property values for the database
// being added to the broker configuration. This error indicates:
// - the net-service-name specified in DGMGRL's CREATE CONFIGURATION
// or ADD DATABASE command is not one that provides access to the
// database being added, or
// - there are no instances running for the database being added.
// *Action: Remove the database from the configuration using the REMOVE
// CONFIGURATION or REMOVE DATABASE command. Make sure that the
// database to be added has at least one instance running and that the
// net-service-name provides access to the running instance. Then
// reissue the CREATE CONFIGURATION or ADD DATABASE command.

Primeira coisa que vem a cabeça é testar a conectividade entre os servidores.

[oracle@anakin scripts]$ tnsping n2


TNS Ping Utility for Linux: Version 10.2.0.3.0 - Production on 12-JUN-2007 00:32:20
Copyright (c) 1997, 2006, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = anakin.mportes.local)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SI
TNS-12541: TNS:no listener

Bingo! Esqueci de subir o listener.

[oracle@anakin scripts]$ lsnrctl start


LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 12-JUN-2007 00:32:25
Copyright (c) 1991, 2006, Oracle. All rights reserved.
Starting /oracle/10g/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.3.0 - Production
System parameter file is /oracle/10g/network/admin/listener.ora
Log messages written to /oracle/10g/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=anakin.mportes.local)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=anakin.mportes.local)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.3.0 - Production
Start Date 12-JUN-2007 00:32:25
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/10g/network/admin/listener.ora
Listener Log File /oracle/10g/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=anakin.mportes.local)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "lx10g" has 1 instance(s).
Instance "lx10g", status UNKNOWN, has 1 handler(s) for this service...
Service "n1_DGMGRL" has 1 instance(s).
Instance "n1dg", status UNKNOWN, has 1 handler(s) for this service...
Service "n2_DGMGRL" has 1 instance(s).
Instance "n2dg", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

Vamos tentar de novo!

[oracle@anakin scripts]$ dgmgrl


DGMGRL for Linux: Version 10.2.0.3.0 - Production
Copyright (c) 2000, 2005, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle
Connected.
DGMGRL> ADD DATABASE n2 AS CONNECT IDENTIFIER IS n2 MAINTAINED AS PHYSICAL;
Database "n2" added

Agora sim, então temos nossa configuração de dataguard criada, porém em estado disable. O comando show
configuration mostra o status da sua configuração.

DGMGRL> show configuration


Configuration
Name: mportes_dg
Enabled: NO
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
n1 - Primary database
n2 - Physical standby database
Current status for "mportes_dg":
DISABLED

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010
Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 6 of 10

Habilite a configuração.

DGMGRL> enable configuration


Enabled.
DGMGRL> show configuration verbose
Configuration
Name: mportes_dg
Enabled: YES
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
n1 - Primary database
n2 - Physical standby database
Current status for "mportes_dg":
Warning: ORA-16610: command 'ENABLE DATABASE n2' in progress

E tenha certa paciência! :-) Aqui é interessante uma dica: abra duas sessões extras e vá ao diretório do alert e faça
um "tail -f alert_..." e veja o broker em ação. Ele fará várias modificações e no momento que voce habilita, ele
começa a aplicar os archives e sincronizar os redologs, ainda falta configurar o modo de aplicação, eu quero que seja
MAXAVAILABILITY.

DGMGRL> show configuration verbose


Configuration
Name: mportes_dg
Enabled: YES
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
n1 - Primary database
n2 - Physical standby database
Current status for "mportes_dg":
SUCCESS

Perfeito. Neste ponto faremos a configuração para que o protection mode seja maxavailability, ou seja, sem perda
de dados com máximo de performance (possível).

DGMGRL> alter configuration set protection mode as maxavailability;


Error: ORA-16627: operation disallowed since no standby databases would remain to support protection mode
Failed.

Ok, ok... Faltou alterar o LogXptMode de ASYNC para SYNC.


Os helps abaixo ajudam muito na medida em que não é frequente o uso do client do broker e ninguem aqui está
participando do campionato mundial de "saber tudo de cabeça".

DGMGRL> help show


Display information about a configuration, database, or instance
Syntax:
SHOW CONFIGURATION;
SHOW DATABASE [VERBOSE] [];
SHOW INSTANCE [VERBOSE] []
[ON DATABASE ];
DGMGRL> show database verbose n1
Database
Name: n1
Role: PRIMARY
Enabled: YES
Intended State: ONLINE
Instance(s):
n1dg
Properties:
InitialConnectIdentifier = 'n1'
LogXptMode = 'ASYNC'
Dependency = ''
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '180'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '2'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = ''
LogFileNameConvert = ''
FastStartFailoverTarget = ''
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName = 'anakin.mportes.local'
SidName = 'n1dg'

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010
Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 7 of 10

LocalListenerAddress = '(ADDRESS=(PROTOCOL=tcp)(HOST=anakin.mportes.local)(PORT=1521))'
StandbyArchiveLocation = '/backup/n1/arch'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.dbf'
LatestLog = '(monitor)'
TopWaitEvents = '(monitor)'
Current status for "n1":
SUCCESS
DGMGRL> help alter
Edit a configuration, database, or instance
Syntax:
EDIT CONFIGURATION SET PROTECTION MODE AS
{MaxProtection|MaxAvailability|MaxPerformance};
EDIT CONFIGURATION SET PROPERTY = ;
EDIT DATABASE SET PROPERTY = ;
EDIT DATABASE RENAME TO ;
EDIT DATABASE SET STATE =
[WITH APPLY INSTANCE = ];
EDIT INSTANCE [ON DATABASE ]
SET AUTO PFILE [ = {|OFF} ];
EDIT INSTANCE [ON DATABASE ]
SET PROPERTY = ;

Alterar nos dois databases.

DGMGRL> edit database n1 set property LogXptMode='SYNC';


Property "logxptmode" updated
DGMGRL> edit database n2 set property LogXptMode='SYNC';
Property "logxptmode" updated
DGMGRL> alter configuration set protection mode as maxavailability;
Succeeded.

Ok, protection mode alterado! O maxavailability é nosso preferido.

DGMGRL> show configuration verbose


Configuration
Name: mportes_dg
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: DISABLED
Databases:
n1 - Primary database
n2 - Physical standby database
Current status for "mportes_dg":
SUCCESS
DGMGRL> exit

Uma vez habilitada a configuração, os bancos já deverão estar sincronizados.


Vamos a alguns testes.

[oracle@anakin scripts]$ export ORACLE_SID=n2dg


[oracle@anakin scripts]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:38:37 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
idle> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME
------------- ------------- ------------- ------------- ------------- --- ---------------- ------------- -------------------
1 1 14 52428800 1 YES CLEARING_CURRENT 604871 12/06/2007 00:38:10
3 1 14 52428800 1 YES CLEARING 604871 12/06/2007 00:38:10
2 1 13 52428800 1 YES CLEARING 604838 12/06/2007 00:37:00
3 rows selected.
idle> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options

Hora das manutenções... :-) Olha como é difícil fazer SWITCHOVER.

[oracle@anakin scripts]$ dgmgrl


DGMGRL for Linux: Version 10.2.0.3.0 - Production
Copyright (c) 2000, 2005, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle
Connected.
DGMGRL> show configuration
Configuration
Name: mportes_dg
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: DISABLED
Databases:
n1 - Primary database
n2 - Physical standby database
Current status for "mportes_dg":

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010
Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 8 of 10

SUCCESS
DGMGRL> switchover to n2
Performing switchover NOW, please wait...
Operation requires shutdown of instance "n1dg" on database "n1"
Shutting down instance "n1dg"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires shutdown of instance "n2dg" on database "n2"
Shutting down instance "n2dg"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "n1dg" on database "n1"
Starting instance "n1dg"...
ORACLE instance started.
Database mounted.
Operation requires startup of instance "n2dg" on database "n2"
Starting instance "n2dg"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "n2"
DGMGRL> show configuration
Configuration
Name: mportes_dg
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: DISABLED
Databases:
n1 - Physical standby database
n2 - Primary database
Current status for "mportes_dg":
SUCCESS
DGMGRL> exit

Pronto! Viu só? Bastou "switchover to " e ele faz tudo. Não deixe de ver os alerts logs com o tail -f.
Vamos verificar!

[oracle@anakin scripts]$ echo $ORACLE_SID


n2dg
[oracle@anakin scripts]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:44:02 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
sys:N1DG> select NAME, OPEN_MODE, PROTECTION_MODE, PROTECTION_LEVEL, REMOTE_ARCHIVE, DATABASE_ROLE,
2 SWITCHOVER_STATUS, DATAGUARD_BROKER, FORCE_LOGGING
3 from v$database
4 /
NAME OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL REMOTE_A DATABASE_ROLE SWITCHOVER_STATUS DATAGUAR FOR
--------- ---------- -------------------- -------------------- -------- ---------------- -------------------- -------- ---
N1DG READ WRITE MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY ENABLED PRIMARY SESSIONS ACTIVE ENABLED YES
1 row selected.
sys:N1DG> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@anakin scripts]$ export ORACLE_SID=n1dg
[oracle@anakin scripts]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:45:25 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
idle> select sequence#, dest_id, creator, registrar, archived, applied, status from v$archived_log order by 1;
SEQUENCE# DEST_ID CREATOR REGISTR ARC APP S
------------- ------------- ------- ------- --- --- -
2 2 ARCH ARCH YES NO A
3 2 ARCH ARCH YES NO A
4 2 ARCH ARCH YES NO A
5 1 ARCH ARCH YES YES A
5 2 ARCH ARCH YES NO A
6 1 ARCH ARCH YES YES A
6 2 ARCH ARCH YES NO A
7 1 ARCH ARCH YES YES A
7 2 ARCH ARCH YES NO A
8 1 ARCH ARCH YES YES A
8 2 ARCH ARCH YES NO A
9 2 ARCH ARCH YES NO A
9 1 FGRD FGRD YES YES A
10 1 ARCH ARCH YES YES A
10 2 ARCH ARCH YES NO A
11 1 ARCH ARCH YES YES A
11 2 ARCH ARCH YES YES A
12 1 ARCH ARCH YES YES A
12 2 ARCH ARCH YES YES A
13 2 LGWR LGWR YES YES A
13 1 FGRD FGRD YES YES A
14 2 LGWR LGWR YES NO A
14 1 FGRD FGRD YES YES A
15 2 LGWR LGWR YES NO A
15 1 FGRD FGRD YES YES A
16 1 FGRD RFS YES YES A
16 2 FGRD FGRD YES NO A

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010
Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 9 of 10

17 1 ARCH RFS YES YES A


18 1 ARCH RFS YES YES A
29 rows selected.
idle> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options

Voltando para o nó N1.

[oracle@anakin scripts]$ dgmgrl


DGMGRL for Linux: Version 10.2.0.3.0 - Production
Copyright (c) 2000, 2005, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle
Connected.
DGMGRL> show configuration
Configuration
Name: mportes_dg
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: DISABLED
Databases:
n1 - Physical standby database
n2 - Primary database
Current status for "mportes_dg":
SUCCESS
DGMGRL> switchover to n1
Performing switchover NOW, please wait...
Operation requires shutdown of instance "n2dg" on database "n2"
Shutting down instance "n2dg"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires shutdown of instance "n1dg" on database "n1"
Shutting down instance "n1dg"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "n2dg" on database "n2"
Starting instance "n2dg"...
ORACLE instance started.
Database mounted.
Operation requires startup of instance "n1dg" on database "n1"
Starting instance "n1dg"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "n1"
DGMGRL>
DGMGRL> show configuration
Configuration
Name: mportes_dg
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: DISABLED
Databases:
n1 - Primary database
n2 - Physical standby database
Current status for "mportes_dg":
SUCCESS
DGMGRL> exit
[oracle@anakin scripts]$ echo $ORACLE_SID
n1dg
[oracle@anakin scripts]$ export ORACLE_SID=n2dg
[oracle@anakin scripts]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jun 12 00:54:16 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
idle> SELECT PROCESS, STATUS,SEQUENCE#,BLOCK#,BLOCKS, DELAY_MINS FROM
2 V$MANAGED_STANDBY;
PROCESS STATUS SEQUENCE# BLOCK# BLOCKS DELAY_MINS
--------- ------------ ------------- ------------- ------------- -------------
ARCH CLOSING 23 1 67 0
ARCH CLOSING 22 1 1 0
MRP0 APPLYING_LOG 24 14 102400 0
RFS IDLE 24 15 1 0
RFS IDLE 0 0 0 0
RFS IDLE 0 0 0 0
6 rows selected.
idle> /
PROCESS STATUS SEQUENCE# BLOCK# BLOCKS DELAY_MINS
--------- ------------ ------------- ------------- ------------- -------------
ARCH CLOSING 23 1 67 0
ARCH CLOSING 22 1 1 0
MRP0 APPLYING_LOG 24 17 102400 0
RFS IDLE 24 18 1 0
RFS IDLE 0 0 0 0
RFS IDLE 0 0 0 0
6 rows selected.
idle> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010
Blog do Marcio Portes: Broker, Dataguard e Real-Time Apply - 10g Page 10 of 10

Uma última consideração, quando configuramos o broker para gerenciar o Dataguard, até a versão 9i, não há
necessidade de abrir o banco, é possível somente levantar os nós em NOMOUNT que ele faz o resto. Já na versão 10g,
é necessário MONTAR o banco para que o broker levante e sincronize os nós.

Um lembrete: Use as instruções acima para exercício em ambiente TESTE e por sua conta e risco!

Labels: how to, New Feature

# posted by Marcio : 7:48 PM

http://mportes.blogspot.com/2007/06/broker-dataguard-e-real-time-apply-10g.html 7/8/2010