lunes, 4 de junio de 2012

Oracle Data Guard Broker configuration example

Oracle Data Guard Broker configuration example

The official Oracle Data Guard Broker docs docs are, of course, the best source for accurate and complete information about how to set up Oracle Data Guard with Oracle Data Guard Broker. They are, however, not always the most useful source, since they generally sacrifice readability for completeness.

This doc should be useful to people setting up a Data Guard Broker with DGMGRL. Managing Data Guard through the Broker is much simpler than managing it manually. DGMGRL is allegedly not as simple as managing Data Guard through Orcle Enterprise Manager Grid Control; however, Grid Control is an extra-cost option that not all of us have.

This procedure makes a number of assumptions that you have made life easy on yourself: you’re using Oracle 11g; you’ve configured a db_recovery_file_dest; your primary and standby databases will be on separate machines with identical directory structures; etc.

Special thanks go out to Chris Ruel of Perpetual Technologies in Indianapolis for his “Oracle 11g Data Guard” presentation, which provided the starting material for this. I have pared away some parts and fleshed out others, but I never would have figured the core of the material out without his help.

I am a beginner at this, and this procedure almost certainly contains steps that are not optimal, and perhaps completely unnecessary. All I can say for certain is that this is one path that got me going successfully.

To begin, assume that you have a primary database server,, hosting a production database, PROD. You have a standby server,, and intend to put a standby Oracle database on it, STBY. Oracle 11g + is installed on both machines.
On stbyserv, create $ORACLE_HOME/dbs/initSTBY.ora with just one parameter:

db_name = PROD

(On Windows, all references to $ORACLE_HOME/dbs should be understood as %ORACLE_HOME%\database.)

On prodserv:

Add these parameters to $ORACLE_HOME/dbs/initPROD.ora:

*.log_archive_dest_10='location=USE_DB_RECOVERY_FILE_DEST, valid_for=(ALL_LOGFILES, ALL_ROLES)'
*.log_archive_dest_2='service="STBY", db_unique_name="STBY", valid_for=(online_logfile,primary_role)'
These new parameters must be incorporated into PROD‘s SPFILE, and the instance must be restarted from the SPFILE:

SQL> shutdown immediate;
SQL> !rm $ORACLE_HOME/dbs/spfilePROD.ora
SQL> startup;
SQL> create spfile from pfile;
SQL> shutdown immediate;
SQL> startup;
Edit $ORACLE_HOME/network/admin files.

On prodserv, add to listener.ora:

(ORACLE_HOME = {oracle home directory here})
On stbyserv, add to listener.ora:

(ORACLE_HOME = {oracle home directory here})
(ORACLE_HOME = {oracle home directory here})
(Note that each machine contains a _DGMGRL entry for the database hosted on the other machine)

tnsnames.ora should have these entries on both machines:

Run lsnrctl reload on both machines. Verify that you can tnsping prod and tnsping stby from both machines.

Under *nix, copy $ORACLE_HOME/dbs/orapwPROD from PROD to $ORACLE_HOME/dbs/orapwSTBY on stbyserv.

Under Windows, on stbyserv:

oradim -new -sid stby -intpwd mypassword
SQL> connect sys@stby as sysdba
SQL> startup nomount;
PROD should have standby logfiles - one more than its number of online redo logfiles, I believe.

SQL> connect sys@prod as sysdba
SQL> select type, count(*) from v$logfile group by type;
SQL> alter database add standby logfile;
SQL> alter database add standby logfile;
SQL> alter database add standby logfile;
SQL> alter database add standby logfile;
RMAN> connect target sys@prod
RMAN> backup database plus archivelog;
Copy the {flash recovery area}/PROD/BACKUPSET/{today} directory from prodserv to stbyserv. Copy it to exactly the same place in the directory structure. Do not change prod to stby in the path.

On stbyserv:

mkdir {oradata directory}/PROD
Again, do not rename PROD to STBY in the directory structure.

RMAN> connect target sys@prod auxiliary sys@stby
RMAN> run {
allocate channel prmy1 type disk;
allocate auxiliary channel stby1 type disk;
duplicate target database
For standby
from active database spfile
set db_unique_name = 'STBY'
set fal_client = 'STBY'
set fal_server = 'PROD'
set standby_file_management = 'AUTO'
set log_archive_config = 'dg_config=(PROD,STBY)'
set log_archive_dest_1 = 'service=PROD ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=PROD'
dorecover nofilenamecheck;
SQL> connect sys@stby as sysdba;
SQL> recover managed standby database disconnect;
SQL> recover managed standby database cancel;
SQL> alter database open read only;
SQL> recover managed standby database using current logfile disconnect;
DGMGRL> connect sys@prod
DGMGRL> create configuration 'standby_config' as
> primary database is 'PROD'
> connect identifier is 'PROD';

DGMGRL> show configuration;
DGMGRL> add database 'STBY' as
> connect identifier is stby;
DGMGRL> enable configuration;
DGMGRL> enable database stby;
Finally ready!

DGMGRL> connect sys@prod
DGMGRL> switchover to 'STBY';

No hay comentarios: