Saturday, November 3, 2012

Non-Dataguard Standby for RAC primary using RMAN

The following are the steps to create a single instance manual standby database for RAC Primary using RMAN without dataguard setup.

on Primary RAC Servers (ed-olraclin1 & ed-olraclin2)

On one of the RAC node take a full RMAN backup of the database on /u01/BACKUP folder, also create the same folder on target dred-olraclin server in same drive and copy the backup set to the DR database server. We will later use this backup set to restore the database to initial build the standby database.

[oracle@ed-olraclin2 ~]$ RMAN TARGET /

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

RMAN> RUN
{
ALLOCATE CHANNEL CH1 TYPE DISK FORMAT '/u01/BACKUP/%d_%T_%s.bak';
BACKUP DATABASE;
BACKUP ARCHIVELOG ALL;
}

RMAN> DELETE NOPROMPT OBSOLETE;

Since the autobackup of controlfile is on ASM disk +TESTDB_FRA, used the new feature of 11.2.0.2 that can copy the files from ASM to local disk using the ASMCMD utility CP copy command as given below,

[oracle@ed-olraclin2 ~]$ export ORACLE_HOME=/u01/oracle/11.2.0/grid
[oracle@ed-olraclin2 ~]$ export ORACLE_SID=+asm2
[oracle@racdb2 ~]$ asmcmd
ASMCMD> pwd
+TESTDB_FRA/testdb/AUTOBACKUP/2012_10_26
ASMCMD> ls
s_790046163.3443.790046167
ASMCMD> CP s_790046163.3443.790046167 /u01/BACKUP/s_790046163.3443.790046167
Copy all the files to dred-olraclin standby database server,

The below copies the directory BACKUP to /u01 on dred-olraclin server,
[oracle@ed-olraclin2 ~] scp -r /u01/BACKUP oracle@dred-olraclin:/u01

or use the below to copy all files from BACKUP directory to /u01/BACKUP directory on dr-olraclin server,
[oracle@ed-olraclin2 ~] scp /u01/BACKUP/* oracle@dred-olraclin:/u01/BACKUP


On Target Single Instance server (dred-olraclin)

Install database software on DR server with same version that of Primary. Or you can use the below article to clone the database home,
http://samiora.blogspot.com/2012/10/cloning-oracle-database-home.html

Create the Listener using 'netca' and database service using 'oradim' utility.

Create the initTEST.ora file and update the parameters accordingly.

SQL> STARTUP NOMOUNT;
[oracle@dred-olraclin ~] RMAN TARGET /
RMAN> RESTORE CONTROLFILE FROM '/u01/BACKUP/s_790046163.3443.790046167';
SQL> ALTER DATABASE MOUNT;
RMAN> RESTORE DATABASE;

Automate archive log apply from primary to standby site

Create .sh scripts and through crontab, automate the process of archive log backup, robocopy the archive backupset to DR server, catalog the archive backups to DR control files and then apply the archives to the DR database using RMAN.

archives_backup.sh
/u01/oracle/11.2.0/bin/rman target / log archive_backup.log @archive_level_0.sql

archive_level_0.sql
run
{
backup format '/u01/archive_backup/%d_%I_%u_%T_%e.rman_arch' archivelog all;
}

copyarchives.sh
scp /u01/archive_backup/* oracle@dred-olraclin:/u01/archive_backup

rman_recovery.sh
rman target / log recovery.log @rman_dr_recovery.sql

rman_dr_recovery.sql
CATALOG START WITH '/u01/archive_backup/' NOPROMPT;
recover database;

Note that 'CATALOG START WITH' statement catalogs all the archives from /u01/archive_backup folder and will skip those files that were already cataloged earlier.

Through crontab, schedule the above scripts archive_backup.sh and copyarchives.sh on any one node of primary RAC server while schedule rman_recovery.sh on DR standby single instance database server.

Verify archive apply and data

You can verify the standby database data by opening the database in read only mode as follows,

SQL> ALTER DATABASE OPEN READ ONLY;

Here verify the data and then restart the database in mount state so that the recovery process continues.

SQL> STARTUP FORCE MOUNT;

To check the last archives been applied run the below query on primary and standby databases,

SQL> SELECT thread#,max(SEQUENCE#) FROM V$ARCHIVED_LOG group by thread#;

THREAD# MAX(SEQUENCE#)
------------------------------------
1                   10701
2                   13430

For any further questions please don't hesitate to email me samiora@gmail.com

No comments: