Thursday, August 4, 2011

Oracle Data Guard step-by-step

Ok.
Here I'm at last!
And 1st my post applies to Oracle Data Guard. I intend to show how to create Data Guard Configuration with Oracle Recovery Manager (RMAN), slightly passing through Database Flash Recovery Area (FRA), Oracle Flashback feature, Recovery Catalog.
The main goal of this post - give step-by-step instruction for building up Data Guard. Just to start it and give it to work.
Why am I using recovery manager (RMAN) in this example? Because without it we'd have to shutdown primary database to create cold backup and up standby database from this cold backup.
All steps bellow are screen-shots of terminal (Putty). If there's no place to fit all steps in one screen-shot I splitted it in several ones.
At the beginning I have to describe environment:
- primary host - IBM570p5, AIX 5.3
- primary host name - prod2.mmk.local
- primary database SID - T
- standby host - IBM520p6, AIX 5.3
- standby host name - ilstal.mmk.local
- standby database SID - TSTB
- database version on both hosts - Oracle 10.2.0.5.3
- recovery catalog SID - CAT
- domain - MMK.LOCAL 
So let's start :)

Step 0 :) SQL*Net
The first of all we need to configure sql*net for our purpose. I'd say that it's the most annoying point of Data Guard Configuration steps.
We planning to use Data Guard Manager (dgmgrl). It's easy just to give command switchover and wait while Data Guard Manager complete role transition between primary and standby database. To give Data Guard Manager ability to shutdown and startup database in new role we need to register instance in listener staticaly (by put entries in SID_LIST clause in listener.ora). Moreover, we need to give GLOBAL_DBNAME in listener.ora following the format db_unique_name_DGMGRL.db_domain. It's important! I see many times when Data Guard Manager couldn't complete operation because of errors in listener.ora.
tnsnames.ora (primary host)

listener.ora (primary host)

tnsnames.ora (standby host)

listener.ora (standby host)


Step 1
I suggest to configure Flash Recovery Area (FRA), put database in archivelog mode and turn on Flashback feature. If you have it configured already, you can pass this step.

Step 2
At this step we configure Recovery Manager (RMAN). But we are sat up Flash Recovery Area at the Step 1, so RMAN uses db_recovery_file_dest as backup destination. And all we have to configure is snapshot control file. It's not necessary for our main goal (creating Data Guard), but I think it useful to put snapshot of controlfile to Flash Recovery Area along with other RMAN backupsets.
We're using recovery catalog, so we need to connect not only to primary database but to catalog database also, and the 1st thing we need to do after connect - is register our database in recovery catalog.

Step 3
Now let's make backup.

Step 4
Now we have to create backup of control file for standby (standby control file)

Step 5
At the Step 6 we'll need to transfer backup, we've created at the Step 3, 4 to standby host. For convenience let's tar our backup.

Step 6
Now let's create on standby host:
- directory structure for standby database
- copy created tar archive (file t.tar) of our primary database backup to standby host
- copy spfileT.ora and orapwT files to standby host

Step 7
Here on standby host we:
- untar t.tar at Flash Recovery Area destination
- rename spfileT.ora to spfileTSTB.ora
- rename orapwT to orapwTSTB

Step 8
 Now create pfile, just for speed up editing standby database parameter.

Step 9
The 1st screen at this step shows pfile of primary database. The second screen shows edited pfile (initTSTB.ora) ready for use by standby database. Changed and added parameters are highlighted with yellow color.
initT.ora


initTSTB.ora
Step 10
Now we create spfile from pfile and sart standby instance.


Step 11
Go to primary host (prod2) and connect RMAN to primary database (target), recovery catalog and auxiliary database (standby database).


Step 12
Now we duplicate primary database to standby host as standby database. (I have to split screens into 3 to show this step)


Step 13
Now we have mounted standby database, but to get ability to turn on real time log apply we have to add standby log file. It's recommended to add more standby log file than online redo log. Oracle recommend use formula (number of logfile groups + 1) * number of instances. In our case we have (3 online redo log + 1) * 1 instance = 4 standby log files. So let's add 4 standby log files. It's a good idea to add standby log files on the primary and standby database at once, so we don't need to add it while role transition back to primary database.


Step 14
Now it's time to turn on data guard broker.


Step 15
Creating data guard configuration

Step 16
Now the time to enable configuration! It's the most shivering step (at least for me :) After a while... let's check...


 

No comments: