There are 3 common Ways to create standby database. You can choose any Way most suitable for you:
- Creating manually via User-Managed Backups
- Using RMAN Backup-based Duplication
- Creating a Standby Database from the active Primary Database without a Backup using RMAN Duplicate
1. Creating a Standby Database via User Managed Backups
We can use a Hot or Cold Database Backup to create the Standby Database. It is only important to create the Standby Controlfile from the Primary after the Backup has completed.
1) Code Backup
For a Cold Backup we simply perform a clean shutdown of the Primary Database and copy all Datafiles to a temporary Location, then startup the Primary Database again:
//in primary database
$ lsnrctl stop
$ sqlplus "/as sysdba"
SQL> shutdown immediate;
$ cp /oracle/oradata/prim_db/*.dbf /backup/
SQL> startup
2) Hot Backup
If you want to use a Host Backup, we have to put the Primary Database into Backup Mode and copy the Datafiles:
//in primary database
SQL> alter database begin backup;
$ cp /oracle/oradata/prim_db/*.dbf /backup/
SQL> alter database end backup;
We can create the Standby Controlfile since the Backup is complete (either Hot or Cold Backup)
//in primary database
SQL> alter database create standby controlfile as ‘/backup/control01.ctl’;
Now the required Files for the Standby Database are complete and we can transfer those to the Standby Database and place them into the Standby Database File-Folder (in our Example to ‘/oracle/oradata/stby_db/’)
Once the Datafiles are there we can set the Environment and first mount the Standby Database
//in standby database
SQL> connect / as sysdba
SQL> startup mount
2. Creating a Standby Database using RMAN (Backup based)
Instead of creating a User-Managed Backup we can also use a RMAN Backup to create the Standby Database.
In this Case we have to create a RMAN Backup of the Primary Database first:
//in primary database
RMAN> connect target /
RMAN> backup database plus archivelog format ‘/backup/STBY_%U’;
Since the Backup already includes the Controlfile, there is no Need to backup or create a Standby Controlfile separately
Transfer all Backuppieces created by the RMAN Backup to the exact same Folder (in our Case ‘/backup/’) on the Standby Database.
Startup nomount the Standby Database, At this Point we can now start the RMAN Duplicate to create the Standby Database.
//in standby database
$ rman target sys/free2go@turkey auxiliary sys/free2go@india
RMAN> duplicate target database for standby nofilenamecheck;
The RMAN Duplicate now extracts the Controlfile and Datafiles from the Backup to build the Standby Database. Once done it mounts the Standby Database
3. Creating a Standby Database using RMAN without Backup (from active Database)
It is now possible to create a Physical Standby Database from the active Primary Database, ie. It is not necessary to create a Backup first. The Blocks are transferred to the Standby Database via the Network during the RMAN Duplicate. Before you decide to use this Option to create your Standby Database you should ensure you sufficient Bandwith available to transfer all Database Blocks of the Primary to the Standby. Depending on the Size of your Primary Database and the Bandwith available it might take long Time to complete this Task. If you have a large Database or a slow Network Connection you may consider to use another Option to create your Standby Database.
The Steps to create the Standby Database that Way are similar to a Backup-based RMAN Duplicate, but we don’t have to take the Backup, we can directly start the RMAN Duplicate from the Standby Site:run in standby
//in standby database
SQL> startup nomount
$ rman target sys/free2go@turkey auxiliary sys/free2go@india
RMAN> duplicate target database for standby from active database nofilenamecheck;
The RMAN Duplicate first copies the Controlfile from the Primary Database as a Standby Controlfile, then mounts the Standby Database with this Conrolfile and creates the Datafiles/copies the Database Blocks from the Primary. Once done the Duplicate finishes and leaves the Database in mount-Status.