|Oracle Data Guard Concepts and Administration
Release 2 (9.2)
Part Number A96653-02
Although Oracle Corporation recommends that you use the managed recovery mode for your physical standby databases, you can also use manual recovery mode. You might choose manual recovery mode for any of the following reasons:
This appendix explains how to work in manual recovery mode. It includes the following topics:
Table B-1 summarizes the basic tasks for setting up a standby database in preparation for manual recovery. This procedure assumes that you plan to connect to the standby database through Oracle Net. If you do not want to use Oracle Net to connect to the standby database, skip steps 4 and 5.
Either make a new backup of the primary database datafiles or access an old backup.
Connect to the primary database and create the standby control file.
Prepare and copy the backup datafiles and standby control file from the primary site to the standby site.
If you want to create an Oracle Net connection to the standby database, create a service name.
If you want to create an Oracle Net connection to the standby database, configure the listener on the standby site so that it can receive requests for connections to the standby instance.
Create the standby initialization parameter file on the standby site and set the initialization parameters for the standby database. Optionally, set
Start the standby instance and mount the standby database.
While connected to the standby database, manually change the names of the primary datafiles and redo logs in the standby control file for all files not automatically renamed using
After you have started and mounted the standby database, you can place it in manual recovery mode. To keep the standby database current, you must manually apply archived redo logs from the primary database to the standby database. Figure B-1 shows a database in manual recovery mode.
This section contains the following topics:
Archived redo logs arrive at the standby site in one of the following ways:
The standby database assumes that the archived log group is in the location specified by either of the following parameters in the standby initialization parameter file:
nis an integer from 1 to 10)
If the archived logs are not in the location specified in the initialization parameter file, you can specify an alternative location using the
FROM option of the
RECOVERstatement to place the standby database in manual recovery mode.
For example, execute one of the following statements:
As the Oracle database server generates archived redo logs, you must continually copy and apply them to the standby database to keep it current.
Manual recovery mode is required in a non-Data Guard environment. A non-Data Guard environment is one in which you manually:
Even if you implement a Data Guard environment, you might occasionally choose to perform manual recovery on the standby database. For example, you might choose to manually resolve an existing archive gap by using manual recovery mode.
An archive gap is a range of archived redo logs created whenever you are unable to apply the next archived redo log generated by the primary database to the standby database. This section contains the following topics:
Typically, archive gaps are resolved automatically without the need for manual intervention. See Section 6.4 for more information about how log apply services automatically recover from gaps in the redo logs.
An archive gap can occur whenever the primary database archives a log, but the log is not archived to the standby site. Because the standby database requires the sequential application of redo logs, media recovery stops at the first missing log encountered.
Archive gaps can occur in the following situations:
One example of an archive gap occurs when you create the standby database from an old backup. For example, if the standby database is made from a backup that contains changes through log 100, and the primary database currently contains changes through log 150, then the standby database requires that you apply logs 101 to 150. Another typical example of an archive gap occurs when you generate the standby database from a hot backup of an open database.
For example, assume the scenario illustrated in Figure B-2.
The following steps occur:
primaryarchives log sequences 4 and 5.
primaryarchives log sequences 6, 7, and 8 to both the primary site and the standby site.
Archived log sequences 4 and 5 are now part of an archive gap, and these logs must be applied to the standby database.
You might be required to shut down the standby database to resolve maintenance issues. For example, you must shut down the standby database when you change a control file parameter, such as
MAXDATAFILE, in the primary database.
To avoid creating archive gaps, follow these rules:
If you violate either of these two rules, then the standby database is down while the primary database is open and archiving. Consequently, the Oracle database server can create an archive gap.
If the standby site is specified as
If you maintain a Data Guard environment, and the network goes down, the primary database might continue to archive to disk but be unable to archive to the standby site. In this situation, archived logs accumulate as usual on the primary site, but the standby instance is unaware of them.
To prevent this problem, you can specify that the standby destination have mandatory status. If the archiving destination is mandatory, then the primary database will not archive any logs until it is able to archive to the standby site. For example, you can set the following in the primary initialization parameter file to make
standby1 a mandatory archiving destination:
One consequence of this configuration is that unless the network problem is fixed, the primary database eventually stalls because it cannot switch into an unarchived online redo log. This problem is exacerbated if you maintain only two online redo logs in your primary database.
To determine if there is an archive gap, query the
V$LOG views. If an archive gap exists, the output of the query specifies the thread number and log sequence number of all logs in the archive gap. If there is no archive gap for a given thread, the query returns no rows.
V$LOG views on the standby database. For example, the following query shows that there is a difference in the
SENT sequence numbers for the destination specified by
DEST_ID=2, indicating that there is a gap:
SQL> SELECT MAX(R.SEQUENCE#) LAST_SEQ_RECD, MAX(L.SEQUENCE#) LAST_SEQ_SENT FROM
2> V$ARCHIVED_LOG R, V$LOG L WHERE
3> R.DEST_ID=2 AND L.ARCHIVED='YES';
LAST_SEQ_RECD LAST_SEQ_SENT ------------- ------------- 7 10
Use the following query to determine the names of the archived redo logs on the local system that must be copied to the standby system that has the gap:
SQL> SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=1 AND DEST_ID=1 AND
2> SEQUENCE# BETWEEN 7 AND 10;
NAME -------------------------------------------------------------------------------- /primary/thread1_dest/arcr_1_7.arc
After you have obtained the log sequence numbers of the logs in the archive gap, you can obtain their filenames by querying the
V$ARCHIVED_LOG view on the primary site. The archived log filenames on the standby site are generated by the
LOG_ARCHIVE_FORMAT parameters in the standby initialization parameter file.
If the standby database is on the same site as the primary database, or the standby database is on a remote site with a different directory structure than the primary database, the filenames for the logs on the standby site cannot be the same as the filenames of the logs archived by the primary database. Before transmitting the archived logs to the standby site, determine the correct filenames for the logs at the standby site.
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE# ---------- ------------- -------------- 1 460 463 2 202 204 3 100 100
If a thread appears in the view, then it contains an archive gap. You need to copy logs from threads 1, 2, and 3.
SQL> SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=1 AND DEST_ID=1 2> AND SEQUENCE# > 459 AND SEQUENCE# < 464; NAME --------------------------------------------------------------------- /primary/thread1_dest/arcr_1_460.arc /primary/thread1_dest/arcr_1_461.arc /primary/thread1_dest/arcr_1_462.arc /primary/thread1_dest/arcr_1_463.arc 4 rows selected
LOG_ARCHIVE_FORMATin the standby initialization parameter file. For example, you discover the following:
These parameter settings determine the filenames of the archived redo logs at the standby site.
LOG_ARCHIVE_FORMAT. For example, enter the following copy commands to copy the archive gap logs required by thread 1:
% cp /primary/thread1_dest/arcr_1_460.arc /standby/arc_dest/log_1_460.arc % cp /primary/thread1_dest/arcr_1_461.arc /standby/arc_dest/log_1_461.arc % cp /primary/thread1_dest/arcr_1_462.arc /standby/arc_dest/log_1_462.arc % cp /primary/thread1_dest/arcr_1_463.arc /standby/arc_dest/log_1_463.arc
Perform similar copy commands to copy archive gap logs for threads 2 and 3.
STANDBY_ARCHIVE_DESTparameter values are not the same, then copy the archive gap logs from the
STANDBY_ARCHIVE_DESTdirectory to the
LOG_ARCHIVE_DESTdirectory. If these parameter values are the same, then you do not need to perform this step.
For example, assume the following standby initialization parameter settings:
Because the parameter values are different, copy the archived logs to the
When you initiate manual recovery, the Oracle database server looks at the
LOG_ARCHIVE_DEST value to determine the location of the logs.
Now that all required logs are in the
STANDBY_ARCHIVE_DEST directory, you can proceed to Section B.3.4 to apply the archive gap logs to the standby database.
After you have copied the logs in the archive gap to the standby site, you can apply them using the
RECOVER AUTOMATIC statement.
AUTOMATIC option automatically generates the name of the next archived redo log needed to continue the recovery operation.
After recovering the available logs, the Oracle database server prompts for the name of a log that does not exist. The reason is that the recovery process does not know about the logs archived to the standby site by the primary database. For example, you might see:
The following error messages are acceptable after recovery cancellation and do not indicate a problem:
Oracle Corporation recommends automatically applying the logs in the archive gap using the
RECOVER MANAGED STANDBY DATABASE clause of the
ALTER DATABASE statement.
Section 6.4 for additional information
Sometimes all of the primary datafiles and redo logs cannot be renamed in the standby control file by conversion parameters. For example, assume that your database has the following datafiles, which you want to rename as shown in the following table:
|Primary Filename||Standby Filename|
You can set
DB_FILE_NAME_CONVERT as follows to convert the filenames for the first two datafiles:
Nevertheless, this parameter will not capture the renaming of
/data/df3.dbf. You must rename this datafile manually in the standby database control file by issuing a SQL statement as follows:
ALTER DATABASEstatement for each datafile requiring renaming, where
old_nameis the old name of the datafile as recorded in the control file and
new_nameis the new name of the datafile that will be recorded in the standby control file:
When you manually rename all of the datafiles that are not captured by the
DB_FILE_NAME_CONVERT parameter, the standby database control file can correctly interpret the log stream during the recovery process.