RMAN Receive Updates For This Category
November 22, 2011 Articles 0 0
Duplicate a Database Using RMAN in Oracle Database 11g Release 2
- Introduction
- Backup-Based Duplication
- Active Database Duplication
Introduction
RMAN has the ability to duplicate, or clone, a database from a backup or from an active database. It is possible to create a duplicate database on a remote server with the same file structure, a remote server will a different file structure or the local server with a different file structure.
The article assumes the duplicate database is being created on a separate server, using the same SID (DB11G) and the same file structure as the source database. Explanations of several other scenarios are available here.
Backup-Based Duplication
Create a backup of the source database, if a suitable one doesn8217;t already exist.
$ rman target=/ RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; RMAN> BACKUP DATABASE PLUS ARCHIVELOG
All subsequent actions occur on the server running the duplicate database.
Create a password file for the duplicate instance.
$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwDB11G password=password entries=10
Add the appropriate entries into the 8220;tnsnames.ora8221; file in the 8220;$ORACLE_HOME/network/admin8221; directory to allow connections to the target database from the duplicate server.
# Added to the tnsnames.ora
DB11G-SOURCE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ol5-112-dup1)(PORT = 1521))
)
(CONNECT_DATA =
(ORACLE_SID = DB11G)
)
)
Create a PFILE for the duplicate database. Since we are duplicating the database onto a separate server with the same filesystem as the original, we don8217;t need to convert the file names. In this case, the PFILE is called 8220;initDB11G.ora8221; and is placed in the 8220;$ORACLE_HOME/dbs8221; directory.
# Minimum Requirement. DB_NAME=DB11G # Convert file names to allow for different directory structure if necessary. #DB_FILE_NAME_CONVERT=(/u01/app/oracle/oradata/DB11G/,/u01/app/oracle/oradata/NEWSID/) #LOG_FILE_NAME_CONVERT=(/u01/app/oracle/oradata/DB11G/,/u02/app/oracle/oradata/NEWSID/)
Create any directories necessary for start the duplicate database.
$ mkdir -p /u01/app/oracle/oradata/DB11G $ mkdir -p /u01/app/oracle/fast_recovery_area/DB11G $ mkdir -p /u01/app/oracle/admin/DB11G/adump
Make the backup files from the source database available to the destination server. That can be done by either copying them to the matching location on the destination server, or placing them on a shared drive. If you are copying the files, you may want to use the following type of commands.
$ scp -r oracle@ol5-112-dup1:/u01/app/oracle/fast_recovery_area/DB11G/archivelog /u01/app/oracle/fast_recovery_area/DB11G $ scp -r oracle@ol5-112-dup1:/u01/app/oracle/fast_recovery_area/DB11G/backupset /u01/app/oracle/fast_recovery_area/DB11G $ scp -r oracle@ol5-112-dup1:/u01/app/oracle/fast_recovery_area/DB11G/autobackup /u01/app/oracle/fast_recovery_area/DB11G
Connect to the duplicate instance.
$ ORACLE_SID=DB11G; export ORACLE_SID $ sqlplus / as sysdba
Start the database in NOMOUNT mode.
SQL> STARTUP NOMOUNT;
With the duplicate database started we can now connect to it from RMAN. For the duplication to work we must connect to the duplicate database (AUXILIARY), but depending on the type of duplication we are doing we may optionally connect to the original database (TARGET) and/or the recovery catalog (CATALOG).
$ ORACLE_SID=DB11G; export ORACLE_SID $ rman AUXILIARY / $ rman TARGET sys/password@DB11G-SOURCE AUXILIARY / $ rman CATALOG rman/password@rman-catalog AUXILIARY / $ rman TARGET sys/password@DB11G-SOURCE CATALOG rman/password@rman-catalog AUXILIARY /
We can then duplicate the database using one of the following commands.
# Backup files are in matching location to that on the source server. # Duplicate database to TARGET's current state. DUPLICATE TARGET DATABASE TO DB11G SPFILE NOFILENAMECHECK; # Duplicate database to TARGET's state 4 days ago. DUPLICATE TARGET DATABASE TO DB11G UNTIL TIME 'SYSDATE-4' SPFILE NOFILENAMECHECK; # Backup files are in a different location to that on the source server. # Duplicate database to the most recent state possible using the provided backups. # Works with just an AUXILIARY connection only. DUPLICATE DATABASE TO DB11G SPFILE BACKUP LOCATION '/source/app/oracle/fast_recovery_area/DB11G' NOFILENAMECHECK;
The time it takes to complete varies depending on the size of the database and the specification of the server. Once the process is finished RMAN produces a completion message and you have your duplicate instance.
Active Database Duplication
Oracle 11g introduced the ability to create duplicate databases directly without the need for a backup. This is known as active database duplication. The process is similar to the backup-based duplication, with a few exceptions.
First, and most obviously, you don8217;t need a backup of the source system, but it does have to be in ARCHIVELOG mode.
The passwords in the password files must match for both servers, so remember to set the correct password when creating the password file on the destination server.
Both the source and destination database servers require a 8220;tnsnames.ora8221; entry for the destination database. In this case I added the following to each server. The destination server still requires the source entry shown in the previous section.
# Added to the tnsnames.ora on source and destination server.
DB11G-DESTINATION =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ol5-112-dup2)(PORT = 1521))
)
(CONNECT_DATA =
(ORACLE_SID = DB11G)
)
)
The destination server requires static listener configuration in a 8220;listener.ora8221; file. In this case I used the following configuration. Remember to restart or reload the listener.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = DB11G.WORLD)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = DB11G)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ol5-112-dup2.localdomain)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
When connecting to RMAN, you must use a connect string for both the target and auxiliary connections.
$ ORACLE_SID=DB11G; export ORACLE_SID $ rman TARGET sys/password@DB11G-SOURCE AUXILIARY sys/password@DB11G-DESTINATION
Include the FROM ACTIVE DATABASE clause in the DUPLICATE command.
DUPLICATE DATABASE TO DB11G FROM ACTIVE DATABASE SPFILE NOFILENAMECHECK;
For more information see:
Recovery Manager (RMAN)
Recovery manager is a platform non-specific utility for coordinating you backup and restoration procedures across multiple servers. In my opinion it8217;s value is limited if you only have on or two instances, but it comes into it8217;s own where large numbers of instances on multiple platforms are used. The reporting features alone mean that you should never find yourself in a position where your data is in danger due to failed backups.
The functionality of RMAN is too diverse to be covered in this article so I shall focus on the basic backup and recovery functionality.
- Create Recovery Catalog
- Register Database
- Cold Backup
- Hot Backup
- Restore & Recover The Whole Database
- Restore & Recover A Subset Of The Database
- Incomplete Recovery
- Lists And Reports
Create Recovery Catalog
First create a user to hold the recovery catalog:
CONNECT sys/password@TSH1 -- Create tablepsace to hold repository CREATE TABLESPACE "TOOLS" DATAFILE 'E:\ORACLE\ORADATA\DDBA1\TOOLS01.DBF' SIZE 10M AUTOEXTEND ON NEXT 1024K EXTENT MANAGEMENT LOCAL; -- Create rman schema owner CREATE USER rman IDENTIFIED BY rman TEMPORARY TABLESPACE temp DEFAULT TABLESPACE tools QUOTA UNLIMITED ON tools; GRANT connect, resource, recovery_catalog_owner TO rman;
Then create the recovery catalog:
c:> rman catalog rman/rman@tsh1 Recovery Manager: Release 8.1.7.0.0 - Production RMAN-06008: connected to recovery catalog database RMAN-06428: recovery catalog is not installed RMAN> create catalog tablespace tools; RMAN-06431: recovery catalog created RMAN> exit Recovery Manager complete. C:>
Register Database
Each database to be backed up by RMAN must be registered:
C:>rman target sys/password@tsh1 rcvcat rman/rman@dba1 msglog 'C:OracleBackupTSH1TSH1_Daily_Backup.log' Recovery Manager: Release 8.1.7.0.0 - Production RMAN-06005: connected to target database: TSH1 (DBID=955315395) RMAN-06008: connected to recovery catalog database RMAN> register database; RMAN-03022: compiling command: register RMAN-03023: executing command: register RMAN-08006: database registered in recovery catalog RMAN-03023: executing command: full resync RMAN-08002: starting full resync of recovery catalog RMAN-08004: full resync complete RMAN>
Existing user-created backups can be added to the catalog using:
catalog datafilecopy 'C:\Oracle\Oradata\TSH1.dbf'; catalog archivelog 'log1', 'log2', 'log3', ... 'logN';
Cold Backup
This RMAN script starts by doing a a clean mount of the database. It then backs up the datafiles, controlfile and archivelogs, with old archive logs deleted in the process. Finally the database is opened.
replace script 'TSH1_daily_backup' {
# make sure database is shutdown cleanly
shutdown immediate;
startup force dba pfile=c:\Oracle\Admin\TSH1\pfile\init.ora;
shutdown immediate;
#Mount the database and start backup
startup mount pfile=c:\Oracle\Admin\TSH1\pfile\init.ora;
# Backup datafile, controlfile and archivelogs
allocate channel ch1 type
disk format 'C:\Oracle\Backup\TSH1\%d_DB_%u_%s_%p';
backup database include current controlfile
tag = 'TSH1_daily_backup';
release channel ch1;
# Open the database
alter database open;
# Archive all logfiles including current
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
# Backup outdated archlogs and delete them
allocate channel ch1 type
disk format 'C:\Oracle\Backup\TSH1\%d_ARCH_%u_%s_%p';
backup archivelog
until time 'Sysdate-2' all
delete input;
release channel ch1;
# Backup remaining archlogs
allocate channel ch1 type
disk format 'C:\Oracle\Backup\TSH1\%d_ARCH_%u_%s_%p';
backup archivelog all;
release channel ch1;
}
The file can be loaded as a stored script and run using the following commands:
RMAN> @c:\Oracle\Backup\TSH1_daily_backup.txt
RMAN> run {execute script TSH1_daily_backup; }
The RMAN output can be a bit unnerving at first. You should expect something like:
RMAN> run {execute script TSH1_daily_backup; }
RMAN-03021: executing script: TSH1_daily_backup
RMAN-03022: compiling command: shutdown
RMAN-06405: database closed
RMAN-06404: database dismounted
RMAN-06402: Oracle instance shut down
RMAN-03022: compiling command: startup
RMAN-06196: Oracle instance started
RMAN-06199: database mounted
RMAN-06400: database opened
Total System Global Area 13375516 bytes
Fixed Size 75804 bytes
Variable Size 12402688 bytes
Database Buffers 819200 bytes
Redo Buffers 77824 bytes
RMAN-03022: compiling command: shutdown
RMAN-06405: database closed
RMAN-06404: database dismounted
RMAN-06402: Oracle instance shut down
RMAN-03022: compiling command: startup
RMAN-06193: connected to target database (not started)
RMAN-06196: Oracle instance started
RMAN-06199: database mounted
Total System Global Area 13375516 bytes
Fixed Size 75804 bytes
Variable Size 12402688 bytes
Database Buffers 819200 bytes
Redo Buffers 77824 bytes
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: ch1
RMAN-08500: channel ch1: sid=14 devtype=DISK
RMAN-03022: compiling command: backup
RMAN-03023: executing command: backup
RMAN-08008: channel ch1: starting full datafile backupset
RMAN-08502: set_count=51 set_stamp=437320255 creation_time=09-AUG-01
RMAN-08010: channel ch1: specifying datafile(s) in backupset
RMAN-08522: input datafile fno=00001 name=C:\ORACLE\ORADATA\TSH1\SYSTEM01.DBF
RMAN-08011: including current controlfile in backupset
RMAN-08522: input datafile fno=00009 name=C:\ORACLE\ORADATA\TSH1\DES601.DBF
RMAN-08522: input datafile fno=00002 name=C:\ORACLE\ORADATA\TSH1\RBS01.DBF
RMAN-08522: input datafile fno=00008 name=C:\ORACLE\ORADATA\TSH1\OEM_REPOSITORY.ORA
RMAN-08522: input datafile fno=00003 name=C:\ORACLE\ORADATA\TSH1\USERS01.DBF
RMAN-08522: input datafile fno=00004 name=C:\ORACLE\ORADATA\TSH1\TEMP01.DBF
RMAN-08522: input datafile fno=00006 name=C:\ORACLE\ORADATA\TSH1\INDX01.DBF
RMAN-08522: input datafile fno=00007 name=C:\ORACLE\ORADATA\TSH1\DR01.DBF
RMAN-08522: input datafile fno=00005 name=C:\ORACLE\ORADATA\TSH1\TOOLS01.DBF
RMAN-08013: channel ch1: piece 1 created
RMAN-08503: piece handle=C:\ORACLE\BACKUP\TSH1\TSH1_DB_1JD11UHV_51_1 comment=NONE
RMAN-08525: backup set complete, elapsed time: 00:05:52
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03022: compiling command: release
RMAN-03023: executing command: release
RMAN-08031: released channel: ch1
RMAN-03022: compiling command: alter db
RMAN-06400: database opened
RMAN-03022: compiling command: sql
RMAN-06162: sql statement: ALTER SYSTEM ARCHIVE LOG CURRENT
RMAN-03023: executing command: sql
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: ch1
RMAN-08500: channel ch1: sid=14 devtype=DISK
RMAN-03022: compiling command: backup
RMAN-03025: performing implicit partial resync of recovery catalog
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03023: executing command: backup
RMAN-08009: channel ch1: starting archivelog backupset
RMAN-08502: set_count=52 set_stamp=437320626 creation_time=09-AUG-01
RMAN-08014: channel ch1: specifying archivelog(s) in backup set
RMAN-08504: input archivelog thread=1 sequence=226 recid=11 stamp=437307841
RMAN-08504: input archivelog thread=1 sequence=227 recid=12 stamp=437309722
RMAN-08504: input archivelog thread=1 sequence=228 recid=13 stamp=437316806
RMAN-08504: input archivelog thread=1 sequence=229 recid=14 stamp=437317665
RMAN-08504: input archivelog thread=1 sequence=230 recid=15 stamp=437319111
RMAN-08504: input archivelog thread=1 sequence=231 recid=16 stamp=437320622
RMAN-08013: channel ch1: piece 1 created
RMAN-08503: piece handle=C:\ORACLE\BACKUP\TSH1\TSH1_ARCH_1KD11UTI_52_1 comment=NONE
RMAN-08525: backup set complete, elapsed time: 00:00:04
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03022: compiling command: release
RMAN-03023: executing command: release
RMAN-08031: released channel: ch1
RMAN> exit
Recovery Manager complete.
The recovery catalog should be resyncronized on a regular basis so that changes to the database structure and presence of new archive logs is recorded. Some commands perform partial and full resyncs implicitly, but a full resync should be scheduled at regular intervals.
resync catalog;
Hot Backup
Hot backups using RMAN are very simple. There is no need to alter the tablespace or database mode.
run {
allocate channel ch1 type disk format 'd:\oracle\backup%d_DB_%u_%s_%p';
backup database;
backup archivelog all;
release channel ch1;
}
Restore & Recover The Whole Database
Recovering from a media failure is as simple as:
run {
startup mount pfile=c:\Oracle\Admin\TSH1\pfile\init.ora;
allocate channel ch1 type disk;
restore database;
recover database;
release channel ch1;
}
This will result in all datafiles being restored then recovered. RMAN will apply archive logs as necessary until the recovery is complete. The sort of results you should expect are:
Recovery Manager: Release 8.1.7.0.0 - Production
RMAN-06005: connected to target database: TSH1 (DBID=955315395)
RMAN-06008: connected to recovery catalog database
RMAN> run {
2> startup mount pfile=c:\Oracle\Admin\TSH1\pfile\init.ora;
3>
4> allocate channel ch1 type disk;
5>
6> restore database;
7> recover database;
8>
9> release channel ch1;
10>}
RMAN-03022: compiling command: startup
RMAN-06193: connected to target database (not started)
RMAN-06196: Oracle instance started
RMAN-06199: database mounted
Total System Global Area 13375516 bytes
Fixed Size 75804 bytes
Variable Size 12402688 bytes
Database Buffers 819200 bytes
Redo Buffers 77824 bytes
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: ch1
RMAN-08500: channel ch1: sid=14 devtype=DISK
RMAN-03022: compiling command: restore
RMAN-03022: compiling command: IRESTORE
RMAN-03023: executing command: IRESTORE
RMAN-08016: channel ch1: starting datafile backupset restore
RMAN-08502: set_count=51 set_stamp=437320255 creation_time=09-AUG-01
RMAN-08089: channel ch1: specifying datafile(s) to restore from backup set
RMAN-08523: restoring datafile 00001 to C:\ORACLE\ORADATA\TSH1\SYSTEM01.DBF
RMAN-08523: restoring datafile 00002 to C:\ORACLE\ORADATA\TSH1\RBS01.DBF
RMAN-08523: restoring datafile 00003 to C:\ORACLE\ORADATA\TSH1\USERS01.DBF
RMAN-08523: restoring datafile 00004 to C:\ORACLE\ORADATA\TSH1\TEMP01.DBF
RMAN-08523: restoring datafile 00005 to C:\ORACLE\ORADATA\TSH1\TOOLS01.DBF
RMAN-08523: restoring datafile 00006 to C:\ORACLE\ORADATA\TSH1\INDX01.DBF
RMAN-08523: restoring datafile 00007 to C:\ORACLE\ORADATA\TSH1\DR01.DBF
RMAN-08523: restoring datafile 00008 to C:\ORACLE\ORADATA\TSH1\OEM_REPOSITORY.ORA
RMAN-08523: restoring datafile 00009 to C:\ORACLE\ORADATA\TSH1\DES601.DBF
RMAN-08023: channel ch1: restored backup piece 1
RMAN-08511: piece handle=C:\ORACLE\BACKUP\TSH1\TSH1_DB_1JD11UHV_51_1 tag=TSH1_DAILY_BACKUP params=NULL
RMAN-08024: channel ch1: restore complete
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03022: compiling command: recover
RMAN-03022: compiling command: recover(1)
RMAN-03022: compiling command: recover(2)
RMAN-03022: compiling command: recover(3)
RMAN-03023: executing command: recover(3)
RMAN-08054: starting media recovery
RMAN-08055: media recovery complete
RMAN-03022: compiling command: recover(4)
RMAN-03022: compiling command: release
RMAN-03023: executing command: release
RMAN-08031: released channel: ch1
RMAN> exit
Recovery Manager complete.
Once this process us complete the database can be opened using the ALTER DATABASE OPEN; command.
Restore & Recover A Subset Of The Database
A subset of the database can be restored in a similar fashion:
run {
sql 'ALTER TABLESPACE users OFFLINE IMMEDIATE';
restore tablespace users;
recover tablespace users;
sql 'ALTER TABLESPACE users ONLINE';
}
Incomplete Recovery
As you would expect, RMAN allows incomplete recovery to a specified time, SCN or sequence number:
run
{
set until time 'Nov 15 2000 09:00:00';
# set until scn 1000; # alternatively, you can specify SCN
# set until sequence 9923; # alternatively, you can specify log sequence number
restore database;
recover database;
}
alter database open resetlogs;
The incomplete recovery requires the database to be opened using the RESETLOGS option.
Lists And Reports
RMAN has extensive listing and reporting functionality allowing you to monitor you backups and maintain the recovery catalog. Here are a few useful commands:
# Show all backup details list backup; # Show items that beed 7 days worth of # archivelogs to recover completely report need backup days = 7 database; # Show/Delete items not needed for recovery report obsolete; delete obsolete; # Show/Delete items not needed for point-in-time # recovery within the last week report obsolete recovery window of 7 days; delete obsolete recovery window of 7 days; # Show/Delete items with more than 2 newer copies available report obsolete redundancy = 2 device type disk; delete obsolete redundancy = 2 device type disk; # Show datafiles that connot currently be recovered report unrecoverable database; report unrecoverable tablespace 'USERS';
It8217;s worth spending some time looking at all the reporting capabilities whilst deciding whether you should switch from shell scripting to RMAN. It might just influence your decision.
RMAN Enhancements in Oracle Database 10g
Oracle 10g includes many RMAN enhancements making it a more complete tool, including the following.
- Flash Recovery Area
- Incrementally Updated Backups
- Fast Incremental Backups
- BACKUP for Backupsets and Image Copies
- Cataloging Backup Pieces
- Improved RMAN Reporting Through V$ Views
- Automatic Instance Creation for RMAN TSPITR
- Cross-Platform Tablespace Conversion
- Enhanced Stored Scripts Commands
- Backupset Compression
- Restore Preview
- Managing Backup Duration and Throttling
- Miscellaneous
- Disk Topology and Automatic Performance Tuning
- Automatic Datafile Creation
- Proxy Archived Log Backups
- Recovery Through Restlogs
- Restore Failover
- Channel Failover
- Deferred Error Reporting
Flash Recovery Area
The flash recovery area is a location on the filesystem or on an ASM disk group that holds files related to recovery.
- Multiplexed controlfiles
- Multiplexed online redo logs
- Archived redo logs
- Flashback logs
- RMAN disk backups
- Files created by
RESTOREandRECOVERYcommands.
Space within the flash recovery area is managed by the database. If there is not enough space to complete an operation obsolete, backed up or redundant files are removed to free up some space.
The following example shows the parameters used to configure the flash recovery area.
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 2G; ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/u01/app/oracle/flash_recovery_area'; ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET = 1440;
The flashback technologies are covered in the Flashback New Features and Enhancements in Oracle Database 10g article.
Incrementally Updated Backups
Using this feature all changes between the SCN of the original image copy and the SCN of the incremental backup are applied to the image copy, winding it forward to make the equivalent of a new database image copy without the overhead of such a backup. The following example shows how this can be used.
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_backup' UNTIL TIME 'SYSDATE - 7';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_backup' DATABASE;
}
The RECOVER COPY... line will not do anything until the script has been running for more than 7 days. The BACKUP INCREMENTAL line will perform a complete backup (level 0) the first day it is run, with all subsequent backups being level 1 incremental backups. After 7 days, the RECOVER COPY... line will start to take effect, merging all incremental backups older than 7 days into the level 0 backup, effectively moving the level 0 backup forward. The effect of this is that you will permanently have a 7 day recovery window with a 7 day old level 0 backup and 6 level 1 incremental backups. Notice that the tag must be used to identify which incremental backups apply to which image copies.
If you wanted to keep your image copy as up to date as possible you might do the following.
RUN {
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_backup' DATABASE;
RECOVER COPY OF DATABASE WITH TAG 'incr_backup';
}
In this example the incremental backup is merged into the image copy as soon as it is completed.
Fast Incremental Backups
There are performance issues associated with incremental backups as the whole of each datafile must be scanned to identify changed blocks. In Oracle 10g it is possible to track changed blocks using a change tracking file. Enabling change tracking does produce a small overhead, but it greatly improves the performance of incremental backups. The current change tracking status can be displayed using the following query.
SELECT status FROM v$block_change_tracking;
Change tracking is enabled using the ALTER DATABASE command.
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
By default the change tracking file is created as an Oracle Managed File (OMF) in the location pointed to by the DB_CREATE_FILE_DEST parameter. An alternate location can be specified using the following command.
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/u01/oradata/MYSID/rman_change_track.f' REUSE;
The tracking file is created with a minumum size of 10M and grows in 10M increments. It8217;s size is typically 1/30,000 the size of the datablocks to be tracked.
Change tracking can be disabled using the following command.
ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
Renaming or moving a tracking file can be accomplished in the normal way using the ALTER DATABASE RENAME FILE command. If the instance cannot be restarted you can simply disable and re-enable change tracking to create a new file. This method does result in the loss of any current change information.
BACKUP for Backupsets and Image Copies
In Oracle 10g the BACKUP command has been extended to allow it to initiate backups of image copies in addition to backupsets. As a result the COPY command has been deprecated in favour of this new syntax.
BACKUP AS COPY DATABASE; BACKUP AS COPY TABLESPACE users; BACKUP AS COPY DATAFILE 1;
RMAN supports the creation of image copies of datafiles and datafile copies, control files and controlfile copies, archived redo logs, and backup pieces.
Cataloging Backup Pieces
It is now possible to manually catalog a backup piece using the CATALOG commands in RMAN. This allows backup files to be moved to alternate locations or manually archived to tape and brought back for restore operations. In Oracle 9i this functionality was only availabale for controlfile copies, archivelog copies and datafile copies. In addition, there are some shortcuts to allow multiple files to be cataloged using a single command. The following examples give the general idea.
# Catalog specific backup piece. CATALOG BACKUPPIECE '/backup/MYSID/01dmsbj4_1_1.bcp'; # Catalog all files and the contents of directories which # begin with the pattern "/backup/MYSID/arch". CATALOG START WITH '/backup/MYSID/arch'; # Catalog all files in the current recovery area. CATALOG RECOVERY AREA NOPROMPT; # Catalog all files in the current recovery area. # This is an exact synonym of the previous command. CATALOG DB_RECOVERY_FILE_DEST NOPROMPT;
The NOPROMPT clause supresses user confirmation for all matching files.
Improved RMAN Reporting Through V$ Views
Oracle 10g includes additional V$ views making the reporting of backup operations more transparent.
- V$RMAN_OUTPUT 8211; This is an in-memory view of the messages reported by RMAN holding a maximum of 32767 rows. Since this information is not recorded in the controlfile it is lost on instance restart.
- V$RMAN_STATUS 8211; This view displays progress and status information for in-progress and complete RMAN jobs. The information for the in-progress jobs is memory only, while the complete job information comes from the controlfile.
- V$BACKUP_FILES 8211; This view display information about RMAN image copies, backupsets and archived logs, similar to the information listed by the RMAN commands
LIST BACKUPandLIST COPY. This view relies on theDBMS_RCVMAN.SETDATABASEprocedure being run to set the database.
The V$RMAN_CONFIGURATION view from Oracle 9i is still available in Oracle 10g.
Automatic Instance Creation for RMAN TSPITR
If a tablespace point-in-time recovery (TSPITR) is initiated with no reference to an auxillary instance RMAN now automatically creates an one. The auxillary instance configuration is based on that of the target database. As a result, any channels required for the restore operations must be present in the target database so they are configured correctly in the auxillary instance. The location of the datafiles for the auxillary instance are specified using the AUXILIARY DESTINATION clause shown below.
RECOVER TABLESPACE users UNTIL LOGSEQ 2400 THREAD 1 AUXILIARY DESTINATION '/u01/oradata/auxdest';
The tablespace is taken offline, restored from a backup, recovered to the specified point-in-time in the auxillary instance and re-imported into the target database. The tablespace in the target database should then be backed up and the tablespace brought back online.
BACKUP TABLESPACE users; SQL "ALTER TABLESPACE users ONLINE";
On successful completion the auxillary instance will be cleaned up automatically. In the event of errors the auxillary instance is left intact to aid troubleshooting.
Cross-Platform Tablespace Conversion
The CONVERT TABLESPACE allows tablespaces to be transported between platforms with different byte orders. The mechanism for transporting a tablespaces is unchanged, this command merely converts the tablespace to allow the transport to work.
The platform of the source and destination platforms can be identified using the V$TRANSPORTABLE_PLATFORM view. The platform of the local server is not listed as no conversion in necessary for a matching platform.
SQL> SELECT platform_name FROM v$transportable_platform; PLATFORM_NAME ------------------------------------ Solaris[tm] OE (32-bit) ... ... Microsoft Windows 64-bit for AMD 15 rows selected.
The tablespace conversion can take place on either the source or the destination server. The following examples show how the command is used in each case.
# Conversion on a Solaris source host to a Linux destincation file.
CONVERT TABLESPACE my_tablespace
TO PLATFORM 'Linux IA (32-bit)'
FORMAT='/tmp/transport_linux/%U';
# Conversion on a Linux destination host from a Solaris source file.
CONVERT DATAFILE=
'/tmp/transport_solaris/my_ts_file01.dbf',
'/tmp/transport_solaris/my_ts_file02.dbf'
FROM PLATFORM 'Solaris[tm] OE (32-bit)'
DB_FILE_NAME_CONVERT
'/tmp/transport_solaris','/u01/oradata/MYDB';
In the first example the converted files are placed in the directory specified by the FORMAT clause. In the second example the specified datafiles are converted to the local servers platform and placed in the correct directory specified by the DB_FILE_NAME_CONVERT clause.
Enhanced Stored Scripts Commands
Scripts can now be defined as global allowing them to be accessed by all databases within the recovery catalog. The syntax for global script manipulation is the same as that for regular scripts with the addition of the GLOBAL clause prior the word SCRIPT. Examples of it8217;s usage are shown below.
CREATE GLOBAL SCRIPT full_backup
{
BACKUP DATABASE PLUS ARCHIVELOG;
DELETE FORCE NOPROMPT OBSOLETE;
}
CREATE GLOBAL SCRIPT full_backup FROM FILE 'full_backup.txt';
RUN { EXECUTE GLOBAL SCRIPT full_backup; }
PRINT GLOBAL SCRIPT full_backup;
LIST GLOBAL SCRIPT NAMES;
LIST ALL SCRIPT NAMES; # Global and local scripts.
REPLACE GLOBAL SCRIPT full_backup
{
BACKUP DATABASE PLUS ARCHIVELOG;
DELETE FORCE NOPROMPT OBSOLETE;
}
REPLACE GLOBAL SCRIPT full_backup FROM FILE 'full_backup.txt';
DELETE GLOBAL SCRIPT 'full_backup';
Backupset Compression
The AS COMPRESSED BACKUPSET option of the BACKUP command allows RMAN to perform binary compression of backupsets. The resulting backupsets do not need to be uncompressed during recovery. It is most useful in the following circumstances:
- You are performing disk-based backup with limited disk space.
- You are performing backups across a network where network bandwidth is limiting.
- You are performing backups to tape, CD or DVD where hardware compression is not available.
The following examples assume that some persistent parameters are configured in a similar manner to those listed below.
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; CONFIGURE DEFAULT DEVICE TYPE TO DISK; CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/backups/MYSID/%d_DB_%u_%s_%p';
The AS COMPRESSED BACKUPSET option can be used explicitly in the backup command.
# Whole database and archivelogs. BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG; # Datafiles 1 and 5 only. BACKUP AS COMPRESSED BACKUPSET DATAFILE 1,5;
Alternatively the option can be defined using the CONFIGURE command:
# Configure compression. CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET; # Whole database and archivelogs. BACKUP DATABASE PLUS ARCHIVELOG;
Compression requires additional CPU cycles which may affect the performance of the database. For this reason it should not be used for tape backups where hardware compression is available.
Restore Preview
The PREVIEW option of the RESTORE command allows you to identify the backups required to complete a specific restore operation. The output generated by the command is in the same format as the LIST command. In addition the PREVIEW SUMMARY command can be used to produce a summary report with the same format as the LIST SUMMARY command. The following examples show how these commands are used.
# Preview RESTORE DATABASE PREVIEW; RESTORE TABLESPACE users PREVIEW; # Preview Summary RESTORE DATABASE PREVIEW SUMMARY; RESTORE TABLESPACE users PREVIEW SUMMARY;
Managing Backup Duration and Throttling
The DURATION clause of the of the BACKUP command restricts the total time available for a backup to complete. At the end of the time window backup is interrupted with any incomplete backupsets discarded. All complete backupsets aer kept and used for future restore operations. The following examples show how it is used.
BACKUP DURATION 2:00 TABLESPACE users; BACKUP DURATION 5:00 DATABASE PLUS ARCHIVELOGS;
Miscellaneous
- Disk Topology and Automatic Performance Tuning 8211; RMAN includes a new disk topology API allowing it to work with more platforms and file types. The information from this API allows RMAN to automatically tune some parameters related to multiplexing and disk buffers, decreasing the need to human intervention.
- Automatic Datafile Creation 8211; RMAN will automatically create missing datafiles in two circumstances. First, when the backup controlfile contains a reference to a datafile, but no backup of the datafile is present. Second, when a backup of the datafile is present, but there is no reference in the controlfile as it was not backed up after the datafile addition.
- Proxy Archived Log Backups 8211; During a proxy backup the media manager takes over full control of the backup process. RMAN is now able to backup and restore proxy copies of archived redo logs if a suitable media manager is used. If a suitable media manager is not available
PROXYclause is ignored and a regular backup is performed. Using thePROXY ONLYresults in an error of a proxy backup cannot be performed. - Restore Failover 8211; RMAN now allows the recovery process to preceed from one incarnation through to another. The contents of the online redo logs are archived before being cleared when an
OPEN RESTLOGSoperation is issued. As a result it is no longer necessary to create a new backup afterOPEN RESTLOGSoperations. - Recovery Through Restlogs 8211; When a backup file contains corrupt blocks or is inaccesible during restore operations (
RECOVER,BLOCKRECOVER, andFLASHBACK DATABASE) RMAN automatically looks for another copy of the file. If one is not available RMAN will use older versions of the file if available. Only if a suitable copy of the file cannot be found will an error be produced. Successful failover operations result in an associated output message. - Channel Failover 8211; When multiple channels are available for the same device type retriable errors in a backup step will automatically be retried on another channel. Retriable errors are usually associated with media managers failing to access tapes or instance failures in RAC environments.
- Deferred Error Reporting 8211; In addition to error messages during the job execution, the error stack at the end of the command execution now displays errors for all failed steps, making identification of failed step easier.
11.1 About RMAN File Management in a Data Guard Configuration
RMAN uses a recovery catalog to track filenames for all database files in a Data Guard environment. A recovery catalog is a database schema used by RMAN to store metadata about one or more Oracle databases. The catalog also records where the online redo logs, standby redo logs, tempfiles, archived redo logs, backup sets, and image copies are created.
11.1.1 Interchangeability of Backups in a Data Guard Environment
RMAN commands use the recovery catalog metadata to behave transparently across different physical databases in the Data Guard environment. For example, you can back up a tablespace on a physical standby database and restore and recover it on the primary database. Similarly, you can back up a tablespace on a primary database and restore and recover it on a physical standby database.
Note:
Backups of logical standby databases are not usable at the primary database.
Backups of standby control files and nonstandby control files are interchangeable. For example, you can restore a standby control file on a primary database and a primary control file on a physical standby database. This interchangeability means that you can offload control file backups to one database in a Data Guard environment. RMAN automatically updates the filenames for database files during restore and recovery at the databases.
11.1.2 Association of Backups in a Data Guard Environment
The recovery catalog tracks the files in the Data Guard environment by associating every database file or backup file with a DB_UNIQUE_NAME. The database that creates a file is associated with the file. For example, if RMAN backs up the database with the unique name of standby1, then standby1 is associated with this backup. A backup remains associated with the database that created it unless you use the CHANGE ... RESET DB_UNIQUE_NAME to associate the backup with a different database.
11.1.3 Accessibility of Backups in a Data Guard Environment
The accessibility of a backup is different from its association. In a Data Guard environment, the recovery catalog considers disk backups as accessible only to the database with which it is associated, whereas tape backups created on one database are accessible to all databases. If a backup file is not associated with any database, then the row describing it in the recovery catalog view shows null for the SITE_KEY column. By default, RMAN associates files whose SITE_KEY is null with the target database.
RMAN commands such as BACKUP, RESTORE, and CROSSCHECK work on any accessible backup. For example, for a RECOVER COPY operation, RMAN considers only image copies that are associated with the database as eligible to be recovered. RMAN considers the incremental backups on disk and tape as eligible to recover the image copies. In a database recovery, RMAN considers only the disk backups associated with the database and all files on tape as eligible to be restored.
To illustrate the differences in backup accessibility, assume that databases prod and standby1 reside on different hosts. RMAN backs up datafile 1 on prod to /prmhost/disk1/df1.dbf on the production host and also to tape. RMAN backs up datafile 1 on standby1 to /sbyhost/disk2/df1.dbf on the standby host and also to tape. If RMAN is connected to database prod, then you cannot use RMAN commands to perform operations with the /sbyhost/disk2/df1.dbf backup located on the standby host. However, RMAN does consider the tape backup made on standby1 as eligible to be restored.
Note:
You can FTP a backup from a standby host to a primary host or vice versa, connect as TARGET to the database on this host, and then CATALOG the backup. After a file is cataloged by the target database, the file is associated with the target database.
11.2 About RMAN Configuration in a Data Guard Environment
In a Data Guard configuration, the process of backing up control files, datafiles, and archived logs can be offloaded to the standby system, thereby minimizing the effect of backups on the production system. These backups can be used to recover the primary or standby database.
RMAN uses the DB_UNIQUE_NAME initialization parameter to distinguish one database site from another database site. Thus, it is critical that the uniqueness of DB_UNIQUE_NAME be maintained in a Data Guard configuration.
Only the primary database must be explicitly registered using the RMAN REGISTER DATABASE command. You do this after connecting RMAN to the recovery catalog and primary database as target.
Use the RMAN CONFIGURE command to set the RMAN configurations. When the CONFIGURE command is used with the FOR DB_UNIQUE_NAME option, it sets the RMAN site-specific configuration for the database with the DB_UNIQUE_NAME you specify.
For example, after connecting to the recovery catalog, you could use the following commands at an RMAN prompt to set the default device type to SBT for the BOSTON database that has a DBID of 1625818158. The RMAN SET DBID command is required only if you are not connected to a database as target.
SET DBID 1625818158; CONFIGURE DEFAULT DEVICE TYPE TO SBT FOR DB_UNIQUE_NAME BOSTON;
11.3 Recommended RMAN and Oracle Database Configurations
This section describes the following RMAN and Oracle Database configurations, each of which can simplify backup and recovery operations:
- Oracle Database Configurations on Primary and Standby Databases
- RMAN Configurations at the Primary Database
- RMAN Configurations at a Standby Database Where Backups are Performed
- RMAN Configurations at a Standby Where Backups Are Not Performed
The configurations described in this section make the following assumptions:
- The standby database is a physical standby database, and backups are taken only on the standby database. See Section 11.9.1 for procedural changes if backups are taken on both primary and standby databases.
- An RMAN recovery catalog is required so that backups taken on one database server can be restored to another database server. It is not sufficient to use only the control file as the RMAN repository because the primary database will have no knowledge of backups taken on the standby database.The RMAN recovery catalog organizes backup histories and other recovery-related metadata in a centralized location. The recovery catalog is configured in a database and maintains backup metadata. A recovery catalog does not have the space limitations of the control file and can store more historical data about backups.A catalog server, physically separate from the primary and standby sites, is recommended in a Data Guard configuration because a disaster at either site will not affect the ability to recover the latest backups.
- All databases in the configuration use Oracle Database 11g Release 1 (11.1).
- Oracle Secure Backup software or 3rd-party media management software is configured with RMAN to make backups to tape.
11.3.1 Oracle Database Configurations on Primary and Standby Databases
The following Oracle Database configurations are recommended on every primary and standby database in the Data Guard environment:
- Configure a flash recovery area for each database (the recovery area is local to a database).The flash recovery area is a single storage location on a file system or Automatic Storage Management (ASM) disk group where all files needed for recovery reside. These files include the control file, archived logs, online redo logs, flashback logs, and RMAN backups. As new backups and archived logs are created in the flash recovery area, older files (which are either outside of the retention period, or have been backed up to tertiary storage) are automatically deleted to make room for them. In addition, notifications can be set up to alert the DBA when space consumption in the flash recovery area is nearing its predefined limit. The DBA can then take action, such as increasing the recovery area space limit, adding disk hardware, or decreasing the retention period.Set the following initialization parameters to configure the flash recovery area:
DB_RECOVERY_FILE_DEST = <mount point or ASM Disk Group> DB_RECOVERY_FILE_DEST_SIZE = <disk space quota>
- Use a server parameter file (SPFILE) so that it can be backed up to save instance parameters in backups.
- Enable Flashback Database on primary and standby databases.When Flashback Database is enabled, Oracle Database maintains flashback logs in the flash recovery area. These logs can be used to roll the database back to an earlier point in time, without requiring a complete restore.
11.3.2 RMAN Configurations at the Primary Database
To simplify ongoing use of RMAN, you can set a number of persistent configuration settings for each database in the Data Guard environment. These settings control many aspects of RMAN behavior. For example, you can configure the backup retention policy, default destinations for backups to tape or disk, default backup device type, and so on. You can use the CONFIGURE command to set and change RMAN configurations. The following RMAN configurations are recommended at the primary database:
- Connect RMAN to the primary database and recovery catalog.
- Configure the retention policy for the database as
ndays:CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF <n> DAYS;
This configuration lets you keep the backups necessary to perform database recovery to any point in time within the specified number of days.
Use the
DELETEOBSOLETEcommand to delete any backups that are not required (per the retention policy in place) to perform recovery within the specified number of days. - Specify when archived logs can be deleted with the
CONFIGURE ARCHIVELOG DELETION POLICYcommand. For example, if you want to delete logs after ensuring that they shipped to all destinations, use the following configuration:CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO ALL STANDBY;
If you want to delete logs after ensuring that they were applied on all standby destinations, use the following configuration:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
- Configure the connect string for the primary database and all standby databases, so that RMAN can connect remotely and perform resynchronization when the
RESYNC CATALOG FROM DB_UNIQUE_NAMEcommand is used. When you connect to the target instance, you must provide a net service name. This requirement applies even if the other database instance from where the resynchronization is done is on the local host. The target and remote instances must use the sameSYSDBApassword, which means that both instances must already have password files. You can create the password file with a single password so you can start all the database instances with that password file. For example, if the TNS alias to connect to a standby in Boston isboston_conn_str, you can use the following command to configure the connect identifier for theBOSTONdatabase site:CONFIGURE DB_UNIQUE_NAME BOSTON CONNECT IDENTIFIER 'boston_conn_str';
Note that the
'boston_conn_str'does not include a username and password. It contains only the Oracle Net service name that can be used from any database site to connect to theBOSTONdatabase site.After connect identifiers are configured for all standby databases, you can verify the list of standbys by using the
LIST DB_UNIQUE_NAME OF DATABASEcommand.
11.3.3 RMAN Configurations at a Standby Database Where Backups are Performed
The following RMAN configurations are recommended at a standby database where backups are done:
- Connect RMAN to the standby database (where backups are performed) as target, and to the recovery catalog.
- Enable automatic backup of the control file and the server parameter file:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
- Skip backing up datafiles for which there already exists a valid backup with the same checkpoint:
CONFIGURE BACKUP OPTIMIZATION ON;
- Configure the tape channels to create backups as required by media management software:
CONFIGURE CHANNEL DEVICE TYPE SBT PARMS '<channel parameters>';
- Specify when the archived logs can be deleted with the
CONFIGURE ARCHIVELOG DELETION POLICYcommand.Because the logs are backed up at the standby site, it is recommended that you configure theBACKED UPoption for the log deletion policy.
11.3.4 RMAN Configurations at a Standby Where Backups Are Not Performed
The following RMAN configurations are recommended at a standby database where backups are not done:
- Connect RMAN to the standby database as target, and to the recovery catalog.
- Enable automatic deletion of archived logs once they are applied at the standby database:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
11.4 Backup Procedures
This section describes the RMAN scripts and procedures used to back up Oracle Database in a Data Guard configuration. The following topics are covered:
- Using Disk as Cache for Tape Backups
- Performing Backups Directly to Tape
Note:
Oracle8217;s Maximum Availability Architecture (MAA) best practices recommend that backups be taken at both the primary and the standby databases to reduce MTTR, in case of double outages and to avoid introducing new site practices upon switchover and failover.
Backups of Server Parameter Files
Prior to Oracle Database 11g, backups of server parameter files (SPFILEs) were assumed to be usable at any other standby database. However, in practice, it is not possible for all standby databases to use the same SPFILE. To address this problem, RMAN does not allow an SPFILE backup taken at one database site to be used at another database site. This restriction is in place only when the COMPATIBLE initialization parameter is set to 11.0.0.
The standby database allows you to offload all backup operations to one specific standby database, except the backups of SPFILE. However, if the COMPATIBLE initialization parameter is set to 11.0.0, the SPFILE can be backed up to disk and cataloged manually at standby sites where backups are written to tape. The additional metadata stored in SPFILE backup sets enables RMAN to identify which database SPFILE is contained in which backup set. Thus, the appropriate SPFILE backup is chosen during restore from tape.
11.4.1 Using Disk as Cache for Tape Backups
The flash recovery area on the standby database can serve as a disk cache for tape backup. Disk is used as the primary storage for backups, with tape providing long term, archival storage. Incremental tape backups are taken daily and full tape backups are taken weekly. The commands used to perform these backups are described in the following sections.
11.4.1.1 Commands for Daily Tape Backups Using Disk as Cache
When deciding on your backup strategy, Oracle recommends that you take advantage of daily incremental backups. Datafile image copies can be rolled forward with the latest incremental backups, thereby providing up-to-date datafile image copies at all times. RMAN uses the resulting image copy for media recovery just as it would use a full image copy taken at that system change number (SCN), without the overhead of performing a full image copy of the database every day. An additional advantage is that the time-to-recover is reduced because the image copy is updated with the latest block changes and fewer redo logs are required to bring the database back to the current state.
To implement daily incremental backups, a full database backup is taken on the first day, followed by an incremental backup on day two. Archived redo logs can be used to recover the database to any point in either day. For day three and onward, the previous day8217;s incremental backup is merged with the datafile copy and a current incremental backup is taken, allowing fast recovery to any point within the last day. Redo logs can be used to recover the database to any point during the current day.
The script to perform daily backups looks as follows (the last line, DELETE ARCHIVELOG ALL is only needed if the flash recovery area is not used to store logs):
RESYNC CATALOG FROM DB_UNIQUE_NAME ALL; RECOVER COPY OF DATABASE WITH TAG 'OSS'; BACKUP DEVICE TYPE DISK INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'OSS' DATABASE; BACKUP DEVICE TYPE SBT ARCHIVELOG ALL; BACKUP BACKUPSET ALL; DELETE ARCHIVELOG ALL;
The standby control file will be automatically backed up at the conclusion of the backup operation because the control file auto backup is enabled.
Explanations for what each command in the script does are as follows:
RESYNC CATALOG FROM DB_UNIQUE_NAME ALLResynchronizes the information from all other database sites (primary and other standby databases) in the Data Guard setup that are known to recovery catalog. ForRESYNC CATALOG FROM DB_UNIQUE_NAMEto work, RMAN should be connected to the target using the Oracle Net service name and all databases must use the same password file.RECOVER COPY OF DATABASE WITH TAG 'OSS'Rolls forward level 0 copy of the database by applying the level 1 incremental backup taken the day before. In the example script just shown, the previous day8217;s incremental level 1 was taggedOSS. This incremental is generated by theBACKUP DEVICE TYPE DISK ... DATABASEcommand. On the first day this command is run there will be no roll forward because there is no incremental level 1 yet. A level 0 incremental will be created by theBACKUP DEVICE TYPE DISK ... DATABASEcommand. Again on the second day there is no roll forward because there is only a level 0 incremental. A level 1 incremental taggedOSSwill be created by theBACKUP DEVICE TYPE DISK ... DATABASEcommand. On the third and following days, the roll forward will be performed using the level 1 incremental taggedOSScreated on the previous day.BACKUP DEVICE TYPE DISK INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'OSS' DATABASECreate a new level 1 incremental backup. On the first day this command is run, this will be a level 0 incremental. On the second and following days, this will be a level 1 incremental.BACKUP DEVICE TYPE SBT ARCHIVELOG ALLBacks up archived logs to tape according to the deletion policy in place.BACKUP BACKUPSET ALLBacks up any backup sets created as a result of incremental backup creation.DELETE ARCHIVELOG ALLDeletes archived logs according to the log deletion policy set by theCONFIGURE ARCHIVELOG DELETION POLICYcommand. If the archived logs are in a flash recovery area, then they are automatically deleted when more open disk space is required. Therefore, you only need to use this command if you explicitly want to delete logs each day.
11.4.2 Performing Backups Directly to Tape
Oracle8217;s Media Management Layer (MML) API lets third-party vendors build a media manager, software that works with RMAN and the vendor8217;s hardware to allow backups to sequential media devices such as tape drives. A media manager handles loading, unloading, and labeling of sequential media such as tapes. You must install Oracle Secure Backup or third-party media management software to use RMAN with sequential media devices.
Take the following steps to perform backups directly to tape, by default:
- Connect RMAN to the standby database (as the target database) and recovery catalog.
- Execute the
CONFIGUREcommand as follows:CONFIGURE DEFAULT DEVICE TYPE TO SBT;
In this scenario, full backups are taken weekly, with incremental backups taken daily on the standby database.
11.4.2.1 Commands for Daily Backups Directly to Tape
Take the following steps to perform daily backups directly to tape:
- Connect RMAN to the standby database (as target database) and to the recovery manager.
- Execute the following RMAN commands:
RESYNC CATALOG FROM DB_UNIQUE_NAME ALL; BACKUP AS BACKUPSET INCREMENTAL LEVEL 1 DATABASE PLUS ARCHIVELOG; DELETE ARCHIVELOG ALL;
These commands resynchronize the information from all other databases in the Data Guard environment. They also create a level 1 incremental backup of the database, including all archived logs. On the first day this script is run, if no level 0 backups are found, then a level 0 backup is created.
The DELETE ARCHIVELOG ALL command is necessary only if all archived log files are not in a flash recovery area.
11.4.2.2 Commands for Weekly Backups Directly to Tape
One day a week, take the following steps to perform a weekly backup directly to tape:
- Connect RMAN to the standby database (as target database) and to the recovery catalog.
- Execute the following RMAN commands:
BACKUP AS BACKUPSET INCREMENTAL LEVEL 0 DATABASE PLUS ARCHIVELOG; DELETE ARCHIVELOG ALL;
These commands resynchronize the information from all other databases in the Data Guard environment, and create a level 0 database backup that includes all archived logs.
The DELETE ARCHIVELOG ALL command is necessary only if all archived log files are not in a flash recovery area.
11.5 Registering and Unregistering Databases in a Data Guard Environment
Only the primary database must be explicitly registered using the REGISTER DATABASE command. You do this after connecting RMAN to the recovery catalog and primary database as TARGET.
A new standby is automatically registered in the recovery catalog when you connect to a standby database or when the CONFIGURE DB_UNIQUE_NAME command is used to configure the connect identifier.
To unregister information about a specific standby database, you can use the UNREGISTER DB_UNIQUE_NAME command. When a standby database is completely removed from a Data Guard environment, the database information in the recovery catalog can also be removed after you connect to another database in the same Data Guard environment. The backups that were associated with the database that was unregistered are still usable by other databases. You can associate these backups with any other existing database by using the CHANGE BACKUP RESET DB_UNIQUE_NAME command.
When the UNREGISTER DB_UNIQUE_NAME command is used with the INCLUDING BACKUPS option, the metadata for all the backup files associated with the database being removed is also removed from the recovery catalog.
11.6 Reporting in a Data Guard Environment
Use the RMAN LIST, REPORT, and SHOW commands with the FOR DB_UNIQUE_NAME clause to view information about a specific database.
For example, after connecting to the recovery catalog, you could use the following commands to display information for a database with a DBID of 1625818158 and to list the databases in the Data Guard environment. The SET DBID command is required only if you are not connected to a database as TARGET. The last three commands list archive logs, database file names, and RMAN configuration information for a database with a DB_UNIQUE_NAME of BOSTON.
SET DBID 1625818158; LIST DB_UNIQUE_NAME OF DATABASE; LIST ARCHIVELOG ALL FOR DB_UNIQUE_NAME BOSTON; REPORT SCHEMA FOR DB_UNIQUE_NAME BOSTON; SHOW ALL FOR DB_UNIQUE_NAME BOSTON;
11.7 Performing Backup Maintenance in a Data Guard Environment
The files in a Data Guard environment (datafiles, archived logs, backup pieces, image copies, and proxy copies) are associated with a database through use of the DB_UNIQUE_NAME parameter. Therefore, it is important that the value supplied for DB_UNIQUE_NAME be unique for each database in a Data Guard environment. This information, along with file-sharing attributes, is used to determine which files can be accessed during various RMAN operations.
File sharing attributes state that files on disk are accessible only at the database with which they are associated, whereas all files on tape are assumed to be accessible by all databases. RMAN commands such as BACKUP and RESTORE, as well as other maintenance commands, work according to this assumption. For example, during a roll-forward operation of an image copy at a database, only image copies associated with the database are rolled forward. Likewise, all incremental backups on disk and all incremental backups on tape will be used to roll forward the image copies. Similarly, during recovery operations, only disk backups associated with the database and files on tape will be considered as sources for backups.
11.7.1 Changing Metadata in the Recovery Catalog
You can use the RMAN CHANGE command with various operands to change metadata in the recovery catalog, as described in the following sections.
Changing File Association from One Standby Database to Another
Use the CHANGE command with the RESET DB_UNIQUE_NAME option to alter the association of files from one database to another within a Data Guard environment. The CHANGE command is useful when disk backups or archived logs are transferred from one database to another and you want to use them on the database to which they were transferred. The CHANGE command can also change the association of a file from one database to another database, without having to directly connect to either database using the FOR DB_UNIQUE_NAME and RESET DB_UNIQUE_NAME TO options.
Changing DB_UNIQUE_NAME for a Database
If the value of the DB_UNIQUE_NAME initialization parameter changes for a database, the same change must be made in the Data Guard environment. The RMAN recovery catalog, after connecting to that database instance, will know both the old and new value for DB_UNIQUE_NAME. To merge the information for the old and new values within the recovery catalog schema, you must use the RMAN CHANGE DB_UNIQUE_NAME command. If RMAN is not connected to the instance with the changed DB_UNIQUE_NAME parameter, then the CHANGE DB_UNIQUE_NAME command can also be used to rename the DB_UNIQUE_NAME in the recovery catalog schema. For example, if the instance parameter value for a database was changed from BOSTON_A to BOSTON_B, the following command should be executed at the RMAN prompt after connecting to a target database and recovery catalog:
CHANGE DB_UNIQUE_NAME FROM BOSTON_A TO BOSTON_B;
Making Backups Unavailable or Removing Their Metadata
Use CHANGE command options such as AVAILABLE, UNAVAILABLE, KEEP, and UNCATALOG to make backups available or unavailable for restore and recovery purposes, and to keep or remove their metadata.
11.7.2 Deleting Archived Logs or Backups
Use the DELETE command to delete backup sets, image copies, archived logs, or proxy copies. To delete only files that are associated with a specific database, you must use the FOR DB_UNIQUE_NAME option with the DELETE command.
File metadata is deleted for all successfully deleted files associated with the current target database (or for files that are not associated with any known database). If a file could not be successfully deleted, you can use the FORCE option to remove the file8217;s metadata.
When a file associated with another database is deleted successfully, its metadata in the recovery catalog is also deleted. Any files that are associated with other databases, and that could not be successfully deleted, are listed at the completion of the DELETE command, along with instructions for you to perform the same operation at the database with which the files are associated (files are grouped by database). Note that the FORCE option cannot be used to override this behavior. If you are certain that deleting the metadata for the non-deletable files will not cause problems, you can use the CHANGE RESET DB_UNIQUE_NAME command to change the metadata for association of files with the database and use the DELETE command with the FORCE option to delete the metadata for the file.
11.7.3 Validating Recovery Catalog Metadata
Use the CROSSCHECK command to validate and update file status in the recovery catalog schema. To validate files associated with a specific database, use the FOR DB_UNIQUE_NAME option with the CROSSCHECK command.
Metadata for all files associated with the current target database (or for any files that are not associated with any database), will be marked AVAILABLE or EXPIRED according to the results of the CROSSCHECK operation.
If a file associated with another database is successfully inspected, its metadata in the recovery catalog is also changed to AVAILABLE. Any files that are associated with other databases, and that could not be inspected successfully, are listed at the completion of the CROSSCHECK command, along with instructions for you to perform the same operation at the database with which the files are associated (files are grouped by site). If you are certain of the configuration and still want to change status metadata for unavailable files, you can use the CHANGE RESET DB_UNIQUE_NAME command to change metadata for association of files with the database and execute the CROSSCHECK command to update status metadata to EXPIRED.
11.8 Recovery Scenarios in a Data Guard Environment
The examples in the following sections assume you are restoring files from tape to the same system on which the backup was created. If you need to restore files to a different system, you need to configure the channels for that system before executing restore and recover commands. You can set the configuration for a nonexistent database using the SET DBID command and the CONFIGURE command with FOR DB_UNIQUE_NAME.
The following scenarios are described in this section:
- Recovery from Loss of Datafiles on the Primary Database
- Recovery from Loss of Datafiles on the Standby Database
- Recovery from Loss of a Standby Control File
- Recovery from Loss of the Primary Control File
- Recovery from Loss of an Online Redo Log File
- Incomplete Recovery of the Primary Database
11.8.1 Recovery from Loss of Datafiles on the Primary Database
You can recover from loss of datafiles on the primary database by using backups or by using the files on a standby database, as described in the following sections.
Issue the following RMAN commands to restore and recover datafiles. You must be connected to both the primary and recovery catalog databases.
RESTORE DATAFILE n,m...; RECOVER DATAFILE n,m...;
Issue the following RMAN commands to restore and recover tablespaces. You must be connected to both the primary and recovery catalog databases.
RESTORE TABLESPACE tbs_name1, tbs_name2, ... RECOVER TABLESPACE tbs_name1, tbs_name2, ...
Using Files On a Standby Database
As of Oracle 11g, you can use files on a standby database to recover a lost datafile. This works well if the standby is up-to-date and the network connection is sufficient enough to support the file copy between the standby and primary.
Start RMAN and take the following steps to copy the datafiles from the standby to the primary:
- Connect to the standby database as the target database:
CONNECT TARGET sys@standby
You are prompted for a password:
target database Password: password
- Connect to the primary database as the auxiliary database:
CONNECT AUXILIARY sys@primary
You are prompted for a password:
target database Password: password
- Back up the datafile on the standby host across the network to a location on the primary host. For example, suppose that
/disk1/df2.dbfis the name of datafile 2 on the standby host. Suppose that/disk8/datafile2.dbfis the name of datafile 2 on the primary host. The following command would copy datafile 2 over the network to/disk9/df2copy.dbf:BACKUP AS COPY DATAFILE 2 AUXILIARY FORMAT '/disk9/df2copy.dbf';
- Exit the RMAN client as follows:
EXIT;
- Start RMAN and connect to the primary database as target, and to the recovery catalog:
CONNECT TARGET sys@primary; target database Password: password CONNECT CATALOG rman@catdb; recovery catalog database Password: password
- Use the
CATALOG DATAFILECOPYcommand to catalog this datafile copy so that RMAN can use it.:CATALOG DATAFILECOPY '/disk9/df2copy.dbf';
Then use the
SWITCH DATAFILEcommand to switch the datafile copy so that/disk9/df2copy.dbfbecomes the current datafile:RUN { SET NEWNAME FOR DATAFILE 2 TO '/disk9/df2copy.dbf'; SWITCH DATAFILE 2; }
11.8.2 Recovery from Loss of Datafiles on the Standby Database
To recover the standby database after the loss of one or more datafiles, you must restore the lost files to the standby database from the backup using the RMAN RESTORE DATAFILE command. If all the archived redo log files required for recovery of damaged files are accessible on disk by the standby database, restart Redo Apply.
If the archived redo log files required for recovery are not accessible on disk, use RMAN to recover the restored datafiles to an SCN/log sequence greater than the last log applied to the standby database, and then restart Redo Apply to continue the application of redo data, as follows:
- Connect SQL*Plus to the standby database.
- Stop Redo Apply using the SQL
ALTER DATABASE ...statement. - In a separate terminal, start RMAN and connect to both the standby and recovery catalog databases (use the
TARGETkeyword to connect to the standby instance). - Issue the following RMAN commands to restore and recover datafiles on the standby database:
RESTORE DATAFILE <n,m,...>; RECOVER DATABASE;
To restore a tablespace, use the RMAN
'RESTORE TABLESPACEtbs_name1, tbs_name2, ...8216; command. - At the SQL*Plus prompt, restart Redo Apply using the SQL
ALTER DATABASE ...statement.
11.8.3 Recovery from Loss of a Standby Control File
Oracle software allows multiplexing of the standby control file. To ensure the standby control file is multiplexed, check the CONTROL_FILES initialization parameter, as follows:
SQL> SHOW PARAMETER CONTROL_FILES; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string <cfilepath1>,<cfilepath2>
If one of the multiplexed standby control files is lost or is not accessible, Oracle software stops the instance and writes the following messages to the alert log:
ORA-00210: cannot open the specified controlfile ORA-00202: controlfile: '/disk1/oracle/dbs/scf3_2.f' ORA-27041: unable to open file
You can copy an intact copy of the control file over the lost copy, then restart the standby instance using the following SQL statements:
SQL> STARTUP MOUNT; SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
You can restore the control file from backups by executing the RESTORE CONTROLFILE command and then the RECOVER DATABASE command. The RECOVER DATABASE command automatically fixes the file names in the control file to match the files existing at that database, and recovers the database to the most recently received log sequence at the database.
The other alternative is to create a new control file from the primary database, copy it to all multiplexed locations, and manually rename the data file names to match files existing on disk.
11.8.4 Recovery from Loss of the Primary Control File
Oracle software allows multiplexing of the control file on the primary database. If one of the control files cannot be updated on the primary database, the primary database instance is shut down automatically.
You can restore the control file from backups by executing the RESTORE CONTROLFILE command and the RECOVER DATABASE command. The RECOVER DATABASE command automatically fixes the file names in the control file to match the files existing at that database, and recovers the database.
The other alternative is to create a new control file using CREATE CONTROLFILE SQL command. It is possible to re-create the control file provided all data files and online logs are not lost.
11.8.5 Recovery from Loss of an Online Redo Log File
Oracle recommends multiplexing the online redo log files. The loss of all members of an online redo log group causes Oracle software to terminate the instance. If only some members of a log file group cannot be written, they will not be used until they become accessible. The views V$LOGFILE and V$LOG contain more information about the current status of log file members in the primary database instance.
When Oracle software is unable to write to one of the online redo log file members, the following alert messages are returned:
ORA-00313: open failed for members of log group 1 of thread 1 ORA-00312: online log 1 thread 1: '/disk1/oracle/dbs/t1_log1.f' ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3
If the access problem is temporary due to a hardware issue, correct the problem and processing will continue automatically. If the loss is permanent, a new member can be added and the old one dropped from the group.
To add a new member to a redo log group, issue the following statement:
SQL> ALTER DATABASE ADD LOGFILE MEMBER 'log_file_name' REUSE TO GROUP n;
You can issue this statement even when the database is open, without affecting database availability.
If all members of an inactive group that has been archived are lost, the group can be dropped and re-created.
In all other cases (loss of all online log members for the current ACTIVE group, or an inactive group which has not yet been archived), you must fail over to the standby database. Refer to Chapter 8 for the failover procedure.
11.8.6 Incomplete Recovery of the Primary Database
Incomplete recovery of the primary database is normally done in cases such as when the database is logically corrupted (by a user or an application) or when a tablespace or datafile was accidentally dropped from database.
Depending on the current database checkpoint SCN on the standby database instances, you can use one of the following procedures to perform incomplete recovery of the primary database. All the procedures are in order of preference, starting with the one that is the least time consuming.
Using Flashback Database Using Flashback Database is the recommended procedure when the Flashback Database feature is enabled on the primary database, none of the database files are lost, and the point-in-time recovery is greater than the oldest flashback SCN or the oldest flashback time. See Section 13.3 for the procedure to use Flashback Database to do point-in-time recovery.
Using the standby database instance This is the recommended procedure when the standby database is behind the desired incomplete recovery time, and Flashback Database is not enabled on the primary or standby databases:
- Recover the standby database to the desired point in time.
RECOVER DATABASE UNTIL TIME 'time';
Alternatively, incomplete recovery time can be specified using the SCN or log sequence number:
RECOVER DATABASE UNTIL SCN incomplete recovery SCN'; RECOVER DATABASE UNTIL LOGSEQ incomplete recovery log sequence number THREAD thread number;
- Open the standby database in read-only mode to verify the state of database.If the state is not what is desired, use the LogMiner utility to look at the archived redo log files to find the right target time or SCN for incomplete recovery. Alternatively, you can start by recovering the standby database to a point that you know is before the target time, and then open the database in read-only mode to examine the state of the data. Repeat this process until the state of the database is verified to be correct. Note that if you recover the database too far (that is, past the SCN where the error occurred) you cannot return it to an earlier SCN.
- Activate the standby database using the SQL
ALTER DATABASE ACTIVATE STANDBY DATABASEstatement. This converts the standby database to a primary database, creates a new resetlogs branch, and opens the database. See Section 9.4 to learn how the standby database reacts to the new reset logs branch.
Using the primary database instance If all of the standby database instances have already been recovered past the desired point in time and Flashback Database is not enabled on the primary or standby database, then this is your only option.
Use the following procedure to perform incomplete recovery on the primary database:
- Use LogMiner or another means to identify the time or SCN at which all the data in the database is known to be good.
- Using the time or SCN, issue the following RMAN commands to do incomplete database recovery and open the database with the
RESETLOGSoption (after connecting to catalog database and primary instance that is inMOUNTstate):RUN { SET UNTIL TIME 'time'; RESTORE DATABASE; RECOVER DATABASE; } ALTER DATABASE OPEN RESETLOGS;
After this process, all standby database instances must be reestablished in the Data Guard configuration.
11.9 Additional Backup Situations
The following sections describe how to modify the backup procedures for other configurations, such as when the standby and primary databases cannot share backup files; the standby instance is only used to remotely archive redo log files; or the standby database filenames are different than the primary database.
11.9.1 Standby Databases Too Geographically Distant to Share Backups
If the standby databases are far apart from one another, the backups taken on them may not be easily accessible by the primary system or other standby systems. Perform a complete backup of the database on all systems to perform recovery operations. The flash recovery area can reside locally on the primary and standby systems (that is, the flash recovery area does not have to be the same for the primary and standby databases).
In this scenario, you can still use the general strategies described in Section 11.8, with the following exceptions:
- Backup files created by RMAN must be tagged with the local system name, and with
RESTOREoperations that tag must be used to restrict RMAN from selecting backups taken on the same host. In other words, theBACKUPcommand must use theTAGsystem name option when creating backups; theRESTOREcommand must use theFROM TAGsystem name option; and theRECOVERcommand must use theFROM TAGsystem nameARCHIVELOG TAGsystem name option. - Disaster recovery of the standby site:
- Start the standby instance in the
NOMOUNTstate using the same parameter files with which the standby was operating earlier. - Create a standby control file on the primary instance using the SQL
ALTER DATABASE CREATE STANDBY CONTROLFILE ASfilename statement, and use the created control file to mount the standby instance. - Issue the following RMAN commands to restore and recover the database files:
RESTORE DATABASE FROM TAG 'system name'; RECOVER DATABASE FROM TAG 'system name' ARCHIVELOG TAG 'system name';
- Restart Redo Apply.
- Start the standby instance in the
The standby instance will fetch the remaining archived redo log files.
11.9.2 Standby Database Does Not Contain Datafiles, Used as a FAL Server
Use the same procedure described in Section 11.4, with the exception that the RMAN commands that back up database files cannot be run against the FAL server. The FAL server can be used as a backup source for all archived redo log files, thus off-loading backups of archived redo log files to the FAL server.
11.9.3 Standby Database File Names Are Different From Primary Database
Note:
As of Oracle Database 11g, the recovery catalog can resynchronize the file names from each standby database site. However, if the file names from a standby database were never resynchronized for some reason, then you can use the procedure described in this section to do so.
If the database filenames are not the same on the primary and standby databases that were never resynchronized, the RESTORE and RECOVER commands you use will be slightly different. To obtain the actual datafile names on the standby database, query the V$DATAFILE view and specify the SET NEWNAME option for all the datafiles in the database:
RUN
{
SET NEWNAME FOR DATAFILE 1 TO 'existing file location for file#1 from V$DATAFILE';
SET NEWNAME FOR DATAFILE 2 TO 'existing file location for file#2 from V$DATAFILE';
…
…
SET NEWNAME FOR DATAFILE n TO 'existing file location for file#n from V$DATAFILE';
RESTORE {DATAFILE <n,m,…> | TABLESPACE tbs_name_1, 2, …| DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE {NOREDO};
}
Similarly, the RMAN DUPLICATE command should also use the SET NEWNAME option to specify new filenames during standby database creation. Or you could set the LOG_FILE_NAME_CONVERT and DB_FILE_NAME_CONVERT parameters.
11.10 Using RMAN Incremental Backups to Roll Forward a Physical Standby Database
In some situations, RMAN incremental backups can be used to synchronize a physical standby database with the primary database. You can use the RMAN BACKUP INCREMENTAL FROM SCN command to create a backup on the primary database that starts at the current SCN of the standby, which can then be used to roll the standby database forward in time.
The steps described in this section apply to situations in which RMAN incremental backups may be useful because the physical standby database either:
- Lags far behind the primary database
- Has widespread nologging changes
- Has nologging changes on a subset of datafiles
Note:
Oracle recommends the use of a recovery catalog when performing this operation. These steps are possible without a recovery catalog, but great care must be taken to correct the file names in the restored control file.
11.10.1 Steps for Using RMAN Incremental Backups
Except where stated otherwise, the following steps apply to all three situations just listed.
- Stop Redo Apply on the standby database:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
- On the standby database, compute the
FROM SCNfor the incremental backup. This is done differently depending on the situation:- On a standby that lags far behind the primary database, query the
V$DATABASEview and record the current SCN of the standby database:SQL> SELECT CURRENT_SCN FROM V$DATABASE; CURRENT_SCN ----------- 233995 - On a standby that has widespread nologging changes, query the
V$DATAFILEview to record the lowestFIRST_NONLOGGED_SCN:SQL> SELECT MIN(FIRST_NONLOGGED_SCN) FROM V$DATAFILE 2> WHERE FIRST_NONLOGGED_SCN>0; MIN(FIRST_NONLOGGED_SCN) ------------------------ 223948 - On a standby that has nologging changes on a subset of datafiles, query the
V$DATAFILEview, as follows:SQL> SELECT FILE#, FIRST_NONLOGGED_SCN FROM V$DATAFILE 2> WHERE FIRST_NONLOGGED_SCN > 0; FILE# FIRST_NONLOGGED_SCN ---------- ------------------- 4 225979 5 230184
- On a standby that lags far behind the primary database, query the
- Connect to the primary database as the RMAN target and create an incremental backup from the current SCN (for a standby lagging far behind the primary) or the lowest
FIRST_NONLOGGED_SCN(for a standby with widespread nologging changes) of the standby database that was recorded in step 2:RMAN> BACKUP INCREMENTAL FROM SCN 233995 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';
If the standby has nologging changes on a subset of datafiles, then create an incremental backup for each datafile listed in the
FIRST_NONLOGGED_SCNcolumn (recorded in step 1), as follows:RMAN> BACKUP INCREMENTAL FROM SCN 225979 DATAFILE 4 FORMAT '/tmp/ForStandby_%U' TAG 'FORSTANDBY'; RMAN> BACKUP INCREMENTAL FROM SCN 230184 DATAFILE 5 FORMAT '/tmp/ForStandby_%U' TAG 'FORSTANDBY';
- If backups were written to shared storage, skip this step. Otherwise, transfer all backup sets created on the primary system to the standby system and then catalog them. There may have been more than one backup file created. The following example, entered at the operating system prompt, uses the
scpcommand to copy the files:scp /tmp/ForStandby_* standby:/tmp
Then, at the RMAN prompt, enter the following command to catalog them:
RMAN> CATALOG START WITH '/tmp/ForStandby';
- Connect to the standby database as the RMAN target and execute the
REPORT SCHEMAstatement to ensure that the standby database site is automatically registered and that the files names at the standby site are displayed:RMAN> REPORT SCHEMA;
- Connect to the standby database as the RMAN target and apply incremental backups. Do the following:
RMAN> STARTUP FORCE NOMOUNT; RMAN> RESTORE STANDBY CONTROLFILE FROM TAG 'FORSTANDBY'; RMAN> ALTER DATABASE MOUNT; RMAN> RECOVER DATABASE NOREDO;
Note:
Oracle recommends that you use a recovery catalog, but if you do not, then just prior to issuing the
RECOVERcommand, you must edit the file names in your control file or use the RMANSET NEWNAMEcommand to assign the datafile names. - On standbys that have widespread nologging changes or that have nologging changes on a subset of datafiles, query the
V$DATAFILEview to verify there are no datafiles with nologged changes. The following query should return zero rows:SQL> SELECT FILE#, FIRST_NONLOGGED_SCN FROM V$DATAFILE 2> WHERE FIRST_NONLOGGED_SCN > 0;
Note:
The incremental backup will become obsolete in 7 days, or you can remove it now using the RMAN
DELETEcommand. - Re-create the standby control file.
- Start Redo Apply on the physical standby database:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE 2> USING CURRENT LOGFILE DISCONNECT FROM SESSION;
