We're here to help!

Manually Creating a Standby Database using RMAN

Follow
Article

When using Dbvisit Standby, it is recommended to make use of the Create Standby Database (CSD) feature provided by Dbvisit Standby to create your standby database. But if due to specific requirements manual creation is required, RMAN can be used to assist in this process.

Note:The steps below are only an example showing you how you can create a standby database manually using RMAN. It is important to note that this is an example and the scripts and steps might need adjustment before being run in any other environment.

The example assume a backup folder is created on both primary and standby servers as /u02/backups/

Backup is performed on primary Node, using compressed rman backup. Backup is then copied to standby node.

Note: The datafile names will need to be renamed when moving from ASM to non ASM when doing the restore/recovery on the standby side.

On the Primary Server

Example backup process:

rman> run
{
backup as compressed backupset
filesperset 2
format '/u02/backups/db_%U'
database;
sql 'alter system archive log current';
backup as compressed backupset
filesperset 50
format '/u02/backups/arch_%U'
archivelog all;
}

rman> backup current controlfile for standby format '/u02/backups/standby.ctl';

Now copy backup files from /u02/backups/* to the standby server /u02/backups/

On the Standby Server

The next section will explain how you perform the restore (creation of the standby database) on the standby server. It is assumed you have copied the backup to the /u02/backups folder on the standby server.

It is recommended that you already have a database password and spfile in place for the standby. The password file should be a copy of the primary database password file and be located in $ORACLE_HOME/dbs. The spfile or pfile could be a copy of the primary parameter file, but should be updated to make sure it reflects a different directory structure if the standby locations are different than the primary.

  1. First Start the Standby Instance in a "nomount" state:
    RMAN> connect target /
    connected to target database (not started)
    RMAN> startup nomount;
    Oracle instance started
    Total System Global Area 392495104 bytes
    Fixed Size 2226832 bytes
    Variable Size 125830512 bytes
    Database Buffers 260046848 bytes
    Redo Buffers 4390912 bytes

    Now that the database instance is running in a nomount state you can start the restore process.

    As the original primary database was making use of Oracle Managed Files (OMF), and in this case we do not want the standby to use OMF, you can make use of the RMAN SET NEWNAME clause to rename the datafiles.

  2. In the second step the controlfile is first restored before mounting the standby database and restoring the datafiles:
    RMAN> run
    2> {
    3> restore standby controlfile from '/u02/backups/standby.ctl';
    4> alter database mount;
    5> set NEWNAME for datafile '/u02/oradata/testdb/testdb/datafile/system.256.781109557' to '/u02/oradata/testdb/system01.dbf';
    6> set NEWNAME for datafile '/u02/oradata/testdb/testdb/datafile/sysaux.257.781109559' to '/u02/oradata/testdb/sysaux01.dbf';
    7> set NEWNAME for datafile '/u02/oradata/testdb/testdb/datafile/undotbs1.258.781109561' to '/u02/oradata/testdb/undotbs101.dbf';
    8> set NEWNAME for datafile '/u02/oradata/testdb/testdb/datafile/users.259.781109561' to '/u02/oradata/testdb/users01.dbf';
    9> restore database;
    10> switch datafile all;
    11> }
    
    Starting restore at 11-MAY-12
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=19 device type=DISK
    channel ORA_DISK_1: restoring control file
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    output file name=/u02/oradata/testdb/control01.ctl
    Finished restore at 11-MAY-12
    database mounted
    released channel: ORA_DISK_1
    executing command: SET NEWNAME
    executing command: SET NEWNAME
    executing command: SET NEWNAME
    executing command: SET NEWNAME
    Starting restore at 11-MAY-12
    Starting implicit crosscheck backup at 11-MAY-12
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=19 device type=DISK
    Crosschecked 16 objects
    Finished implicit crosscheck backup at 11-MAY-12
    Starting implicit crosscheck copy at 11-MAY-12
    using channel ORA_DISK_1
    Finished implicit crosscheck copy at 11-MAY-12
    searching for all files in the recovery area
    cataloging files...
    no files cataloged
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    channel ORA_DISK_1: restoring datafile 00001 to /u02/oradata/testdb/system01.dbf
    channel ORA_DISK_1: restoring datafile 00004 to /u02/oradata/testdb/users01.dbf
    channel ORA_DISK_1: reading from backup piece /u02/backups/db_0dnanfjb_1_1
    channel ORA_DISK_1: piece handle=/u02/backups/db_0dnanfjb_1_1 tag=TAG20120511T140219
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:42
    channel ORA_DISK_1: starting datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    channel ORA_DISK_1: restoring datafile 00002 to /u02/oradata/testdb/sysaux01.dbf
    channel ORA_DISK_1: restoring datafile 00003 to /u02/oradata/testdb/undotbs101.dbf
    channel ORA_DISK_1: reading from backup piece /u02/backups/db_0enanfke_1_1
    channel ORA_DISK_1: piece handle=/u02/backups/db_0enanfke_1_1 tag=TAG20120511T140219
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:21
    Finished restore at 11-MAY-12
    datafile 1 switched to datafile copy
    input datafile copy RECID=5 STAMP=783016919 file name=/u02/oradata/testdb/system01.dbf
    datafile 2 switched to datafile copy
    input datafile copy RECID=6 STAMP=783016919 file name=/u02/oradata/testdb/sysaux01.dbf
    datafile 3 switched to datafile copy
    input datafile copy RECID=7 STAMP=783016919 file name=/u02/oradata/testdb/undotbs101.dbf
    datafile 4 switched to datafile copy
    input datafile copy RECID=8 STAMP=783016919 file name=/u02/oradata/testdb/users01.dbf

    If we now review the standby database by making use of the "report schema" command we notice the temp file is still pointing to the wrong location.

    RMAN> report schema
    2> ;
    RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
    Report of database schema for database with db_unique_name TESTDB
    List of Permanent Datafiles
    File Size(MB) Tablespace RB segs Datafile Name

    
    1 700 SYSTEM *** /u02/oradata/testdb/system01.dbf
    2 510 SYSAUX *** /u02/oradata/testdb/sysaux01.dbf
    3 45 UNDOTBS1 *** /u02/oradata/testdb/undotbs101.dbf
    4 5 USERS *** /u02/oradata/testdb/users01.dbf
    List of Temporary Files
    File Size(MB) Tablespace Maxsize(MB) Tempfile Name

    
    1 20 TEMP 32767 /u02/oradata/testdb/testdb/tempfile/temp.263.782911857

    Update the location of the tempfile:

    RMAN> run
    2> {
    3> set newname for tempfile '/u02/oradata/testdb/testdb/tempfile/temp.263.782911857' to '/u02/oradata/testdb/temp01.dbf';
    4> switch tempfile all;
    5> }
    executing command: SET NEWNAME
    renamed tempfile 1 to /u02/oradata/testdb/temp01.dbf in control file
    RMAN> report schema;
    RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
    Report of database schema for database with db_unique_name TESTDB
    List of Permanent Datafiles
    File Size(MB) Tablespace RB segs Datafile Name

    
    1 700 SYSTEM *** /u02/oradata/testdb/system01.dbf
    2 510 SYSAUX *** /u02/oradata/testdb/sysaux01.dbf
    3 45 UNDOTBS1 *** /u02/oradata/testdb/undotbs101.dbf
    4 5 USERS *** /u02/oradata/testdb/users01.dbf
    List of Temporary Files
    File Size(MB) Tablespace Maxsize(MB) Tempfile Name

    
    1 20 TEMP 32767 /u02/oradata/testdb/temp01.dbf
    RMAN> exit

You should now have a standby database ready to start receiving and applying logs.

Anton Els July 05, 2013 12:18

Have more questions? Submit a request

Comments