DataGuard Implementation steps

November 12, 2016 by S4

Filed under Oracle

Last modified November 12, 2016

DataGuard Implementation steps

  1. Create similar directory structure on Primary and Standby nodes for storing backups and Archive log files.

In the test Dataguard Machine, the following Directories were created.

Eg mkdir /misc/arch – for specifying a local location of the archive files

mkdir /misc/backup – for specifying a backup location for RMAN backup.

Please note that this is the directory that stores the RMAN backup and archivelogs in the Primary machine.

 

  1. Copy the network files to the backup directory – tnsnames.ora, listener.ora and sqlnet.ora and make necessary changes in the files in the RAC nodes and in the Standby database node.
    • Please note that this step is optional and the files could be built on the standby itself if it is more comfortable

 

  1. Make necessary changes in init file for the standby.

Amongst others specifically edit On Standby initfile/spfile , the following parameters

  • Db_unique_name=stdby

This parameter is substituted for the erstwhile used “lock_name_space” parameter (as it probably sounded a bit awkard??)

  • Instance_name=stdby
  • Optional Thread=1
  • Undo_tablespace=undotbs1
  • Log_archive_dest_2= service=RACDBCOE VALID_FOR=(online_logfiles,PRIMARY_ROLE) db_unique_name=racdbcoe
    • RACDBCOE is the tnsnames entry for the RAC listener with client side load-balancing enabled

 

Other Parameters

  1. background_dump_dest
  2. user_dump_dest
  3. core_dump_dest
  4. audit_file_dest
  5. db_recovery_file_dest

 

RAC spfile

  1. Log_archive_config=’dg_config=(racdbcoe, stdby)’
  2. Log_archive_dest_2=’service=stdby valid_for = (online_logfiles,primary_role) db_unique_name=stdby’
  3. Standby_file_management=AUTO
  4. Fal_server=’stdby’
  5. Fal_client=’racdbcoe’

 

  1. Enable force logging on the primary database.
    • Alter database force logging
      • The significance of this parameter is that it overrides transaction/ object level nologging specified and ensures that everything is logged , thus helping to keep the standby in sync at all times.
  1. Generate backup using RMAN [ along with the archivelog files ] ( We could also accomplish it with dbms_file_transfer package to take the archives and RMAN backups from the backup area. But the easy way was chosen).
    • Backup database plus archivelog;
      • Actually we could have accomplished this by connecting to target database and auxiliary database and issued the command

Duplicate target database for standby;

and Oracle would have created a standby database and mounted it.

But since in many environments we might not be able to directly connect with Production to duplicate, the following methodology is followed.

We could run into real issues if we don’t have a shared area for collecting archivelogs ( if Primary is a RAC database). So make sure that one of the log_archive_dest_n is set to USE_DB_RECOVERY_FILE_DEST which would generally be a shared area.

 

  1. Generate Standby controlfile from Primary Database
    • Backup current controlfile for standby format ‘/misc/backup/stdby.ctl’
      • Controlfile backup should be done after the backup has been generated as in the above step so that the backup is recorded in the controlfile that we have generated.

 

  1. Transfer the backupset and standby control file to the machine where we want to restore the files. This could be achieved using one of the file transfer mechanisms ftp, scp, rcp et.al.

 

  1. Start up the standby instance in nomount.
    • Startup nonount

 

  1. Connect to the database using RMAN.
    • RMAN target /

 

  1. Restore the standby controlfile.
    • Restore standby controlfile from ‘/misc/backup/stdby.ctl’;

 

  1. Mount the database.
    • Alter database mount;

 

  1. Catalog the backuppiece(s) ( from Step 5 ) in the standby host. In case if necessary, replicate the exact on disk structure of the backupset path in the standby host.
    • This is an optional step if step 6 followed step 5. In case if step 6 was done before step 5 during the actual execution, then this step should be followed to record the presence of valid backups in the standby controlfile.

 

  1. Restore the backup. ().
    • Restore database;
      • Since the db_file_create_dest is specified, the files will be placed in the given Directory in OMF Format

 

  1. set standby_file_management=MANUAL.
    • Since we need to add the standby redo log files

 

  1. Clear the online logfiles This will actually create the logfiles in the OMF format.
    • Alter database clear logfile group [n].

 

  1. Add standby logfiles to the standby instance.
    • Since we plan to use the synchronous on-line log transfer between production and the dataguard.

 

  1. set the standby_file_management to AUTO.

 

  1. Create spfile for the dataguard, if not created already.

 

  1. Put the standby in managed recovery mode.
    • Alter database recover managed standby database using current logfile nodelay disconnect

 

  1. Bring up the listener.

 

  1. A menu handling the basic operations of Dataguard is provided. The name of the Shell script is st_menu and can be downloaded from mighty portal.

 

Dataguard Broker Configuration

 

DG broker

  • ensure dg_broker_start=TRUE in spfile of Primary and Dataguard.

 

  • set dg_broker_config_file1, dg_broker_config_file2 for each instance separately

Also set the eg broker config files for dataguard in the same way.…

  • dg_broker_config_file1=’+DATA/RACDBCOE/dg1racdbcoe.dat’ sid=’<insntance>’
  • dg_broker_config_file2=’+DATA/RACDBCOE/dg2racdbcoe.dat’ sid=’<instance>’
    • there will be untold misery if you set it as sid=’*’. You have to set it individually for each of the instance. Else you are a goner!!!

 

  • Create a dataguard broker configuration that includes the primary database and all the secondary databases
    • dgmgrl /

create configuration racdg as

primary database is racdbcoe

connect identifier is racdbcoe;

 

  • Check if things are OK by checking the configuration using
    • Show configuration.

 

  • Add the standby database to the newly added configuration
    • Add database stdby as connect identifier is stdby maintained as physical

 

  • Enable the recently added configuration
    • Enable

 

  • Check if things are fine using the commands
    • Show database verbose racdbcoe
    • Show database verbose stdby

Leave a Comment