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

Create 11g Clone or Standby Database using RMAN

Following are the steps of Creating a Standby or a Clone Database using Rman Duplicate From Active Database for 11.2.0.2 database.

The following are the steps to create a standby or a clone of oracle database using RMAN,

1) Create a parameter file for the clone or standby

2) Add the following three parameters to the standby or clone database parameter file, even if the paths are identical on both the source and standby or clone servers:

*._compression_compatibility='11.2.0'
*.db_file_name_convert=('target path','auxilary path'....)
*.log_file_name_convert=('target path','auxilary path'....)

3) Copy the passwordfile from the source database to the clone or standby Oracle_Home/database for windows folder or $Oracle_Home/dbs for Linux.

4) Configure the network on the clone or standby server so that you can connect to the database

5) Startup nomount the clone or standby database

6) Add a tnsnames.ora entry to the clone or standby on your source database server

7) Check that you can connect to the clone or standby database as sysdba

8) On the Primary server connect to the source database and clone or standby database (auxiliary) using RMAN

D:\> RMAN TARGET / AUXILIARY sys/password@prodclon

Recovery Manager: Release 11.2.0.2.0 - Production on Fri Nov 2 9:02:41 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD (DBID=7119395273)
Connected to auxiliary database: PRODCLON (not mounted)

9) Use the following syntax to duplicate to a clone (use as many channels as CPU’s you may dedicate):

run
{
allocate channel c1 type disk;
allocate auxiliary channel cr1 type disk;
duplicate target database to 'prodclon' from active database nofilenamecheck;
}

10) Use the following syntax to duplicate for standby (use as many channels as CPU’s you may dedicate):

run
{
allocate channel c1 type disk;
allocate auxiliary channel cr1 type disk;
duplicate target database for standby from active database nofilenamecheck;
}

If you have any questions regarding the above steps then please don't hesitate to email me samiora@gmail.com