Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A standby database is a special copy of the primary database. Once created, Dbvisit Standby can be used to automatically keep the standby database up to date with the primary database. Dbvisit Standby can automatically create the standby database, but in some cases it may be desirable to manually create the standby database. These steps show two different methods for manually creating the standby database. Please choose one method.

Creating a standby database (using

...

RMAN)

Oracle's Rman can be used to create a standby database without shutting down the primary database. You do not need to create an Rman catalog.The easiest way to use Rman is to create the backup on disk. However, this requires significant free space if your database is very large. It is also possible to save the backup to tape. In this case you would need a tape or media manager as part of your Rman configuration.On some systems it may be possible to use an external Hard Disk (through USB) to backup the database and then use this disk to restore the database on the standby server.

Example:

This example backs up the database to disk

The examples below is making use of Disk Based backups:   

  • The assumption in this example is that the primary and standby database servers are exactly the same:
    • Same Operating System and version
    • Same Database Software and Patch Levels
    • Same directory structure is used

  • Backups are stored in /u02/backup/devdb.
  • This location exists on both the primary and the standby database servers.  
  • The backup will be created on the primary database using RMAN and stored in /u02/backup/devdb/
  • The backup must then be copied manually to the standby server to /u02/backup/devdb/  (This can be done using scp command)
  • Once the backup is copied to the standby server, RMAN is used to perform the restore/creation of the standby database.

Preliminary steps:

1. Setup the same Linux or Unix user accounts (Oracle software owner) and groups (dba) on the standby server (preferably with the same uid and the same gid), as on the primary server.

...

3. Install Oracle software on the standby server preferably in the same location as on the primary server.

4. Copy the init.ora database parameter (pfile/spfile) file for the production database on the production server to the standby server .into $ORACLE_HOME/dbs

5. Copy the /var/opt /oracle/oratab or /etc/oratab file from the production server to the standby server, of make sure the entry for the database you want to create the standby database for is in the standby oratab file.

6. Copy the password file $ORACLE_HOME/dbs/orapw<$ORACLE_SID> from the production server to the standby server. You may have to create a new password file with the orapwd utility.

7. Copy the spfile from the production server to the standby server if it is used.

8.  

7. Create a directory on the primary and standby server where the full backup of the database can be kept. In this example /oracleu02/orabase/backupfilebackup/devdb will be used.

On the

...

primary server:

9. Listener must be running on the standby server and you must be able to connect from primary server to the standby database (the SQL*Net port must be open on any firewall between the two servers).

10. Start the standby database in nomount mode.

Section
Column
width5%

 

Column
width95
Panel
bgColorCCC
$sqlplus "/ as sysdba" 
SQL> startup nomount

On the primary server:

11. Set the Oracle environment to the production database (with the oraenv command in Linux/UNIX) and start Rman:8. Set the Oracle environment to the production database (with the oraenv command in Linux/UNIX) - in the example the database is called "devdb"

No Format
oracle@dbvlin101[/home/oracle]: . oraenv
ORACLE_SID = [oracle] ? devdb
The Oracle base remains unchanged with value /u01/app/oracle
oracle@dbvlin101[/home/oracle]:

 

9.  Run the following RMAN commands to backup the primary database:

Note that TAGs are used to make it easier to restore.  For more detail on RMAN and using "tags" please see the Oracle documentation

 

Section
Column
width5%

 

Column
width95%
Panel
bgColorCCC
$ rman 
connect target / 
run{ 
change archivelog all crosscheck; 
allocate channel ch1 type disk; 
backup incrementalas levelcompressed 0backupset database format '/oracleu02/orabasebackup/backupfiledevdb/bk_inc0_%s_%p'setsize=8250000 include current controlfile for standby ; db_%U' tag 'BKP1_DB';
sql "alter system archive log current"; 
backup archivelog all format '/oracleu02/orabasebackup/backupfiledevdb/al_%s_%parc_%U' tag 'BKP1_ARC'; 
backup current controlfile for standby format '/u02/backup/devdb/standby-ctl-%U';
release channel ch1; 
}

12. Copy files from /oracle/orabase/backupfile to 10. Once the backup is finished, copy the backup files located in  /u02/backup/devdb/  to same location on standby server.

13. Create an alias entry for the standby database in the tnsnames.ora file on the production server. In this example the alias is called standbydb.

14. Start Rman and create the standby database. The password for sys must be the password from the password file Example:  scp  /u02/backup/devdb/* dbvlin102: /u02/backup/devdb/

 

On the standby server:

11. Set the environment for the standby database (similar to step 8 above using oraenv utility), then start the standby database in nomount mode.

Section
Column
width5%

 

Column
width95
Panel
bgColorCCC
$rman
connect auxiliary sys/password@standbydb
connect target / 
run { 
allocate auxiliary channel ch1 type disk; 
duplicate target database for standby dorecover nofilenamecheck; 
release channel ch1; 
}

...

oracle@dbvlin102[/home/oracle]: . oraenv
ORACLE_SID = [oracle] ? devdb
The Oracle base remains unchanged with value /u01/app/oracle
oracle@dbvlin102[/home/oracle]: sqlplus "/ as sysdba"
SQL> startup nomount

12. Start RMAN on the standby server and create the standby database. 

Important: the following assume that the database parameter file was already copied from the primary to standby server and that the directory structure and settings for the standby server is exactly the same as the primary.  (This is the ideal and recommended configuration for a standby database to match production)

Section
Column
width5%

 

Column
width95
Section
Column
width5%

 

Column
width95
Panel
bgColorCCC
SID_LIST_LISTENER = 
(SID_LIST = 
(SID_DESC = 
(SID_NAME = PLSExtProc) 
(ORACLE_HOME = /U01/app/oracle/product/10.2.0/db_1) 
(PROGRAM = extproc) 

(SID_DESC =
(SID_NAME = dbvisitp)
(ORACLE_HOME = /U01/app/oracle/product/10.2.0/db_1)
)
)
Where dbvisitp is the name of your database
Panel
bgColorCCC
$rmanSQL>
connect startuptarget nomount
SQL> alter database mount standby database;
Note

If the following message is received from Rman:

Section
Column
width5%

 

Column
width95
Panel
bgColorCCC
RMAN> connect auxiliary sys/password@standbydb 
RMAN-00571: =========================================================== 
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== 
RMAN-00571: =========================================================== 
RMAN-04006: error from auxiliary database: ORA-12528: TNS:listener: all appropriate instances are blocking new connections

Then the following should be added (in red) to the listener.ora on the standby server:


RMAN> restore standby controlfile from '/u02/backup/devdb/standby-ctl-1qq7t60h_1_1';
RMAN> sql 'alter database mount';
RMAN> restore database from tag 'BKP1_DB';
RMAN> recover database from tag 'BKP1_ARC';

NOTE: You will get an error from the recover command as the above command as it is looking for archive logs that will not exist in the BKP1_ARC backup.  It will however apply the required logs from this backup.  

 

13. Standby database is now complete. RMAN has started the standby database in mount standby mode which is correct for Dbvisit Standby to continue. 



Creating a standby database (traditional method)

The process involves making a full backup of your production database on the primary server. This can be either a hot or a cold backup. If a hot backup is used, then the archive log files created during the backup will also need to be copied to the standby database.

...