Friday, January 21, 2011

Creation of a Physical Standby database with RMAN


1. Install Oracle binaries on the standby host 

Oracle binaries (the same patch level etc.) must be installed on the standby host if is not already done. 


2. Put the primary database in archivelog mode

Put the primary database in archivelog mode if is not already done. 

SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;


3. Create the same directory structures

Create the same directory structure for the data files, control files, redo log files, archivelog files. 

If the data or redo log file directories are different the following line ( adapted to your case) must be added in pfile:

db_file_name_convert =("/u01/oradata/PRD","/u02/oradata/PRD")
log_file_name_convert =("/u01/oradata/PRD","/u02/oradata/PRD")



$ export ORACLE_SID=PRD 
$ rman target=/ 
Note: if you are not sure that rman from your $ORACLE_HOME is used run
$ which rman  

RMAN> run {
    allocate channel c1 type disk;
    backup format '/u02/backups/PRD/DataFile_t%t_s%s_p%p' database;
    backup current controlfile for standby format '/u02/backups/PRD/sby_t%t_s%s_p%p';
    sql 'alter system archive log current';
    backup format '/u02/backups/PRD/ArhAll_t%t_s%s_p%p' archivelog all;
    release channel c1;
}



Copy all the RMAN file (created for this backup) to the standby host in the same location (/u02/backups/PRD).



If the primary database use a spfile, create a pfile (connected as sys):
SQL> create pfile from spfile;

Copy the pfile from the primary database host to the standby database host to $ORACLE_HOME/dbs directory. 
Add in the standby pfile the line: db_unique_name=PRD_sb           (if the database name/ instance name is PRD )



On the standby host configure the tnsnames.ora in order to point to the primary database. Try to connect from the standby database host to the primary database as sys. 

If you receive ORA-01031: insufficient privileges when conn sys/password as sysdba, please assure that:

  a) the password file has a good name (orapwPRD , if the instance is PRD; the file name is case sensitive)
      To recreate the password file you can use orapwd:
      orapwd file=$ORACLE_HOME/dbs/orapwsid password=new_sys_password entries=15
 
  b) pfile/ spfile remote_login_passwordfile parameter is set to EXCLUSIVE or SHARE.

  If the problem is not fixed please check the Metalink note 18089.1 


8. Create the standby database

$ export ORACLE_SID=PRD
$ rman target sys/sys_password@PRD auxiliary /
RMAN> RUN {
               allocate channel C1 device type disk;
               allocate auxiliary channel C2 device type disk;
               duplicate target database for standby nofilenamecheck dorecover;
               }
RMAN>

(The database will be in mount state !!!) 

To check the status of the new database you can run (connected as sys or system):

SQL> select NAME, OPEN_MODE, DB_UNIQUE_NAME, DATABASE_ROLE from V$database;

 



No comments:

Post a Comment