This chapter describes backup strategies using Oracle Recovery Manager (RMAN) with Oracle Data Guard and standby databases. RMAN can perform backups with minimal effect on the primary database and quickly recover from the loss of individual data files, or the entire database. RMAN and Oracle Data Guard can be used together to simplify the administration of an Oracle Data Guard configuration.
This chapter contains the following topics:
About RMAN File Management in an Oracle Data Guard Configuration
About RMAN Configuration in an Oracle Data Guard Environment
Registering and Unregistering Databases in an Oracle Data Guard Environment
Performing Backup Maintenance in an Oracle Data Guard Environment
Note:
Because a logical standby database is not a block-for-block copy of the primary database, you cannot use a logical standby database to back up the primary database.See Also:
Oracle Database Backup and Recovery User's Guide for more information about RMAN concepts and about using RMAN in an Oracle Data Guard environment
Oracle Database Backup and Recovery Reference for detailed information about all RMAN commands used in this chapter
RMAN uses a recovery catalog to track filenames for all database files in an Oracle 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.
RMAN commands use the recovery catalog metadata to behave transparently across different physical databases in the Oracle 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 an Oracle Data Guard environment. RMAN automatically updates the filenames for database files during restore and recovery at the databases.
The recovery catalog tracks the files in the Oracle 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.
The accessibility of a backup is different from its association. In an Oracle 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 data file 1 on prod
to /prmhost/disk1/df1.dbf
on the production host and also to tape. RMAN backs up data file 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 asTARGET
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.In an Oracle Data Guard configuration, the process of backing up control files, data files, 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 an Oracle 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;
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 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 12.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 an Oracle Data Guard configuration because a disaster at either site will not affect the ability to recover the latest backups.
See Also:
Oracle Database Backup and Recovery User's Guide for more information about managing a recovery catalogAll 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.
The following Oracle Database configurations are recommended on every primary and standby database in the Oracle Data Guard environment:
Configure a fast recovery area for each database (the recovery area is local to a database).
The fast recovery area is a single storage location on a file system or Oracle Automatic Storage Management (Oracle 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 fast 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 fast 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 fast recovery area:
DB_RECOVERY_FILE_DEST = <mount point or Oracle ASM Disk Group> DB_RECOVERY_FILE_DEST_SIZE = <disk space quota>
See Also:
Oracle Database Backup and Recovery User's Guide for more information about configuring a fast recovery areaUse 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 fast recovery area. These logs can be used to roll the database back to an earlier point in time, without requiring a complete restore.
See Also:
Oracle Database Backup and Recovery User's Guide for more information about enabling Flashback DatabaseTo simplify ongoing use of RMAN, you can set a number of persistent configuration settings for each database in the Oracle 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 n
days:
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 DELETE
OBSOLETE
command 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 POLICY
command. 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_NAME
command 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 same SYSDBA
(or SYSBACKUP
) password, 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 is boston_conn_str
, you can use the following command to configure the connect identifier for the BOSTON
database 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 the BOSTON
database 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 DATABASE
command.
See Also:
Oracle Database Backup and Recovery User's Guide for more information about RMAN configurations
Oracle Database Backup and Recovery Reference for more information about the RMAN CONFIGURE
command
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 data files 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>';
Because the archived logs are backed up at the standby database, Oracle recommends that you configure the BACKED UP
option for the log deletion policy:
CONFIGURE ARCHIVELOG DELETION POLICY BACKED UP n TIMES TO DEVICE TYPE SBT;
See Also:
Oracle Database Backup and Recovery User's Guide for more information about enabling deletion policies for archived redo logsThe 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 (this is also applicable to all terminal databases when the cascading or far sync instance features are in use):
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
This section describes the RMAN scripts and procedures used to back up Oracle Database in an Oracle Data Guard configuration. The following topics are covered:
Note:
Oracle'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
All backup operations can be offloaded to a single standby database, except backups of the SPFILE. Backups of the SPFILE can only be restored to the database from which they were backed up.
For databases that are not backed up, Oracle recommends that you at least back up the SPFILE to a known local disk location. If the SPFILE backups need to be further backed up to tape, you can copy them to the database site where backups to tape have been configured. The SPFILE backups can then be cataloged at that database using the following RMAN command:
CATALOG START WITH '<SPFILE backup directory>';
Then back up the SPFILE backups to tape:
BACKUP BACKUPSET ALL;
When the SPFILE needs to be restored for a specific database, the appropriate SPFILE backup is restored from disk or tape.
The fast 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.
When deciding on your backup strategy, Oracle recommends that you take advantage of daily incremental backups. Data file image copies can be rolled forward with the latest incremental backups, thereby providing up-to-date data file 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 day's incremental backup is merged with the data file 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 fast 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 ALL
Resynchronizes the information from all other database sites (primary and other standby databases) in the Oracle Data Guard setup that are known to recovery catalog. For RESYNC CATALOG FROM DB_UNIQUE_NAME
to 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 day's incremental level 1 was tagged OSS
. This incremental is generated by the BACKUP DEVICE TYPE DISK ... DATABASE
command. 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 the BACKUP DEVICE TYPE DISK ... DATABASE
command. Again on the second day there is no roll forward because there is only a level 0 incremental. A level 1 incremental tagged OSS
will be created by the BACKUP DEVICE TYPE DISK ... DATABASE
command. On the third and following days, the roll forward will be performed using the level 1 incremental tagged OSS
created on the previous day.
BACKUP DEVICE TYPE DISK INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'OSS' DATABASE
Create 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 ALL
Backs up archived logs to tape according to the deletion policy in place.
BACKUP BACKUPSET ALL
Backs up any backup sets created as a result of incremental backup creation.
DELETE ARCHIVELOG ALL
Deletes archived logs according to the log deletion policy set by the CONFIGURE ARCHIVELOG DELETION POLICY
command. If the archived logs are in a fast 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.
Oracle's Media Management Layer (MML) API lets third-party vendors build a media manager, software that works with RMAN and the vendor'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 CONFIGURE
command 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.
See Also:
Oracle Database Backup and Recovery User's Guide for more information about how to configure RMAN for use with a media managerTake 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 Oracle 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 fast recovery area.
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:
RESYNC CATALOG FROM DB_UNIQUE_NAME ALL; BACKUP AS BACKUPSET INCREMENTAL LEVEL 0 DATABASE PLUS ARCHIVELOG; DELETE ARCHIVELOG ALL;
These commands resynchronize the information from all other databases in the Oracle 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 fast recovery area.
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 an Oracle Data Guard environment, the database information in the recovery catalog can also be removed after you connect to another database in the same Oracle 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 unregistered is also unregistered from the recovery catalog.
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 database in the Oracle 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;
The files in an Oracle Data Guard environment (data files, 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 an Oracle 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. The incremental backups on disk associated with that database and any 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.
See Also:
Oracle Database Backup and Recovery Reference for detailed information about RMAN commandsYou 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 an Oracle 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 Oracle 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 the value of the DB_UNIQUE_NAME
initialization parameter changes for a database, the same change must be made in RMAN so that it is aware of the new DB_UNIQUE_NAME
. For example, perform the following steps to change the database with DB_UNIQUE_NAME
of BOSTON_A
to BOSTON_B
:
In the initialization parameter file or SQL, change the DB_UNIQUE_NAME
initialization parameter from BOSTON_A
to BOSTON_B
.
In RMAN, connect to any database in the Oracle Data Guard environment as target database and connect to the recovery catalog. Then execute the CHANGE
command:
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.
See Also:
Oracle Database Backup and Recovery Reference for more information about the RMANCHANGE
commandUse 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 file'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.
See Also:
Oracle Database Backup and Recovery Reference for more information about the RMANDELETE
commandUse 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
.
See Also:
Oracle Database Backup and Recovery Reference for more information about the RMANCROSSCHECK
commandThe following recovery scenarios are described in this section:
Recovery from Loss of Files on the Primary or Standby Database
Actions Needed on Standby After TSPITR or Tablespace Plugin at Primary
As of Oracle Database 12c Release 1 (12.1), you can restore and recover files over the network by connecting to a physical standby database that contains the required files. This can be useful when you want to restore lost data files, control files, or tablespaces on a primary database using the corresponding files on the physical standby database. You can also use the same process to restore files on a physical standby database by using the primary database.
For an example of how to restore and recover files by connecting over the network, see Oracle Database Backup and Recovery User's Guide.
Note:
In releases prior to Oracle Database 12c, to recover from loss of files on the primary, you used the RMAN recovery catalog, and the RMANBACKUP
, CATALOG DATAFILE
, and SWITCH DATAFILE
commands. To recover from loss of files on the standby, you used the RESTORE
and RECOVER
commands. Those methods are no longer necessary as of Oracle Database 12c. If you need information about using them, refer to Oracle Database 11g documentation.See Also:
Oracle Database Backup and Recovery User's Guide for more information about using RMAN to restore and recover files over the network
If all online log members for the current ACTIVE
group or for an inactive group which has not yet been archived are lost, then you must fail over to the standby database. Refer to Chapter 9 for the failover procedure.
For information about how to recover from the loss of online redo log files in other circumstances, see Oracle Database Backup and Recovery User's Guide.
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 data file 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 15.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. Be sure to stop the managed redo process (MRP) before issuing the following command:
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 DATABASE
statement. This converts the standby database to a primary database, creates a new resetlogs branch, and opens the database. See Section 10.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 RESETLOGS
option (after connecting to catalog database and primary instance that is in MOUNT
state):
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 Oracle Data Guard configuration.
After an RMAN tablespace point-in-time recovery (TSPITR) is performed at the primary, the recovered data files have a new system change number (SCN), and are therefore treated like new data files at the primary. These data files cannot be automatically created at the standby.
Likewise, when a new plugged in tablespace is added to the primary database, the data files are treated like new data files at the primary.
The managed redo process (MRP) at the standby stops when the Redo Apply process encounters creation of these new files. The required new data files must be copied and restored to the standby. You can do this using either backups or a direct copy from the primary. For example, to copy all files that belong to a tablespace that has undergone an RMAN TSPITR, you can use the following RMAN command:
RMAN> RESTORE TABLESPACE <tbs_name1, tbs_name2> FROM SERVICE <tnsalias-of-primary>
Note that the number of disk channels allocated will be as per RMAN configurations. So, if CONFIGURE DEVICE TYPE DISK PARALLELISM 4
is executed, then 4 disk channels will be used to pull the files from the primary database.
When the new data files are available at the standby, MRP should be restarted to continue applying the logs.
See Also:
Oracle Database Backup and Recovery User's Guide for more information about RMAN TSPITR
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.
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 fast recovery area can reside locally on the primary and standby systems (that is, the fast 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 12.8, with the following exceptions:
Backup files created by RMAN must be tagged with the local system name, and with RESTORE
operations that tag must be used to restrict RMAN from selecting backups taken on the same host. In other words, the BACKUP
command must use the TAG
system name option when creating backups; the RESTORE
command must use the FROM TAG
system name option; and the RECOVER
command must use the FROM TAG
system name ARCHIVELOG TAG
system name option.
Disaster recovery of the standby site:
Start the standby instance in the NOMOUNT
state 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 AS
filename 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.
The standby instance will fetch the remaining archived redo log files.
Use the same procedure described in Section 12.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.
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 data file names on the standby database, query the V$DATAFILE
view and specify the SET NEWNAME
option for all the data files 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.
See Also:
Section 15.5, "Creating a Standby Database That Uses OMF or Oracle ASM" for information about precedence rules when both theDB_FILE_NAME_CONVERT
and DB_CREATE_FILE_DEST
parameters are set on the standbyAs of Oracle Database 12c, RMAN lets you restore or recover files by connecting, over the network, to a physical standby database that contains the required files. You can restore an entire database, data files, control files, spfile, or tablespaces. Restoring files over the network is very useful in scenarios where you need to synchronize the primary and standby databases.
RMAN restores database files, over the network, from a physical standby database by using the FROM
SERVICE
clause of the RESTORE
command. The FROM
SERVICE
clause provides the service name of the physical standby database from which the files must be restored. During the restore operation, RMAN creates backup sets, on the physical standby database, of the files that need to be restored and then transfers these backup sets to the target database over the network.
Note:
In releases prior to Oracle Database 12c, to restore and recover files over the network, you used the RMANBACKUP INCREMENTAL FROM SCN
command to create a backup on the primary database that started at the current SCN of the standby, and was then used to roll the standby database forward in time. That manual, multi-step method is not necessary as of Oracle Database 12c. If you need information about using that method, refer to Oracle Database 11g documentation.See Also:
Oracle Database Backup and Recovery User's Guide for an example of using RMAN to roll forward a physical standby database and synchronize it with the primary database
Oracle Database Backup and Recovery User's Guide for more information about using RMAN to restore and recover files over the network
In addition to supporting complete database recovery and complete datafile recovery at a standby, RMAN supports point-in-time recovery (PITR) of a multitenant container database (CDB) at a standby.
To perform a CDB PITR at a standby, connect to the CDB as root and issue the RMAN BACKUP
, RESTORE
, and RECOVER
commands as necessary.
Be aware that when a CDB PITR is performed on a standby, any pluggable databases (PDBs) that were in a disabled state before the CDB PITR will become enabled. To return a PDB to a disabled state, connect to it, ensure it is closed (the OPEN_MODE
column in the V$PDBS
view should show a value of MOUNTED
), and then execute the SQL statement ALTER
PLUGGABLE
DATABASE
DISABLE
RECOVERY
. (This SQL statement is available as of Oracle Database 12c Release 12.1 (12.1.0.2).)
The ALTER
PLUGGABLE
DATABASE
DISABLE
RECOVERY
statement takes all data files belonging to the PDB offline and disables recovery for the PDB. The data files that belong to the PDB will not be part of any recovery session until the PDB is enabled again. Any new data files created while recovery is disabled are created as unnamed files and are marked offline.
To bring all data files that belong to a PDB back online and enable it for recovery, connect to it, ensure it is closed (the OPEN_MODE
column in the V$PDBS
view should show a value of MOUNTED
), and issue the SQL statement ALTER
PLUGGABLE
DATABASE
ENABLE
RECOVERY
. (This SQL statement is available as of Oracle Database 12c Release 12.1 (12.1.0.2).)
To check whether recovery is enabled or disabled on a PDB, query the V$PDBS
view as follows:
SQL> SELECT RECOVERY_STATUS FROM V$PDBS;
Note:
Files that are brought online or offline as a result of anALTER
PLUGGABLE
DATABASE
[
ENABLE
|
DISABLE
]
operation remain in that state even if you flashback the database to a point before the operation was performed.See Also:
Section 15.9 for information about actions needed on a standby after a PDB PITR on a primary
Section 12.8.4 for information about actions needed on a standby after TSPITR or tablespace plugin at the primary