Oracle8i Standby Database Concepts and Administration
Release 2 (8.1.6)

Part Number A76995-01

Library

Product

Contents

Index

Go to previous page Go to next page

2
Preparing a Standby Database

This chapter describes how to set up a standby database in preparation for manual or managed recovery. It includes the following topics:

Assessing the Environment Before Standby Database Creation

After you have decided to implement a standby database, you should address several important issues relating to the environment in which the standby database will reside. How you answer the questions depends on the purpose of the standby database: protection against data loss or corruption, or supplemental reporting.

How Should the Standby Database Be Updated?

The first question is whether the standby database will run in a managed standby environment (see Configuration Options). In this environment, the primary database automatically archives redo logs to the standby site so long as the standby instance is started.

Whether you implement a managed standby environment depends on your situation. The following table offers suggestions:

Purpose  Standby Environment 

Disaster protection 

Managed 

Protection against data corruption 

Managed with a time lag, or non-managed 

Supplemental reporting on a data warehouse or database that does not change frequently 

Managed or non-managed 

Supplemental reporting on a data warehouse or database that changes frequently 

Managed 

If you choose a managed standby environment, then you can run the standby database in managed recovery mode so that it applies archived redo logs automatically. Whether you plan to use the database for reporting or protection against data loss, this option requires the least user intervention. If you choose a non-managed environment, then you must transfer the logs manually and perform manual recovery of the standby database.

Should the Standby Database Reside on a Separate Host?

If you can, it is almost always better to place a standby database on a separate host, for the following reasons:

How Should You Configure the Online Redo Logs in the Primary Database?

Both the size of the online redo logs and the frequency with which they switch affect the generation of archived redo logs at the primary site. Table 2-1 describes some consequences of various online redo log configurations.

Table 2-1  Consequences of Online Redo Log Configuration
If the online redo logs are  Then 

Small 

The logs switch more frequently. If you maintain a managed standby environment, frequent switches can cause:

  • Significant network traffic caused by continual log transfer.

  • Difficulties for manual recovery of a standby database that cannot begin managed recovery because of a gap sequence. For a discussion of gap sequences, see Resolving a Gap Sequence Before Initiating Managed Recovery.

  • Additional protection against data loss, because fewer transactions are contained in each archived redo log.

 

Large 

The redo logs switch less frequently, but more transactions are stored in each file. This situation can:

  • Increase the transfer time of a single log, creating a possible network bottleneck.

  • Increase the amount of potential data loss if the primary database fails before it can archive its redo logs.

 

Numerous 

The primary database does not have to reuse redo logs as often as it does when you maintain the minimum of two. Because Oracle is not forced to archive at every log switch, a disaster can wipe out multiple logs before the primary database archives them to the standby site. 

How Should You Connect to the Standby Database After Failover?

If the primary database fails, users should be able to connect to the activated standby database seamlessly. For example, one simple solution is to configure the client tnsnames.ora files or Oracle Names server to contain an entry for the standby service name. After failover, users can connect to the database using the standby service name instead of the primary service name.

Other failover solutions include:

When deciding on a method, weigh the simplicity of the solution against the need for a seamless failover.

Setting Up a Standby Database: Basic Tasks

After you have decided to create a standby database and determined where to place it, you can begin preparing it. The procedure of standby database creation differs depending on whether you plan to set up a managed standby environment or a non-managed standby environment.

This section contains the following topics:

Preparing a Standby Database for Managed Recovery: Basic Tasks

Setting up a standby database for managed recovery requires you to perform a series of different tasks. After you have completed the preparation and initiated managed recovery, the standby database automatically and continuously applies redo logs as they are received from the primary database.

Table 2-2 summarizes the basic tasks for setting up a standby database and synchronizing it so it is ready to begin managed recovery.

Table 2-2  Task List: Preparing for Managed Recovery
  Task  Procedure 

Either make a new backup of the primary database datafiles or access an old backup. 

Creating the Standby Datafiles 

Connect to the primary database and create the standby control file. 

Creating the Standby Control File 

Copy the backup datafiles and control file from the primary site to the standby site. 

Transferring Files to the Standby Site 

Create a service name for the standby database. 

Configuring the tnsnames.ora File on the Primary Site 

Configure the listener on the standby site so that it can receive the archived redo logs from the primary site. 

Configuring the listener.ora File on the Standby Site 

Set the initialization parameters for the primary database. 

Configuring the Primary Database Initialization Parameter File 

Create the standby initialization parameter file and set the initialization parameters for the standby database. Depending on your configuration, you may need to set filename conversion parameters. 

Configuring the Standby Database Initialization Parameter File 

Start the standby instance and mount the standby database. 

Starting the Standby Instance 

Manually change the names of the primary datafiles and redo logs in the standby control file for all files not automatically renamed using DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT in step 7. If step 7 renamed all files, skip this step. 

Manually Renaming Standby Files Not Captured by Conversion Parameters 

10 

Manually enable initialization parameter changes on the primary database so that it can initiate archival to the standby site. 

Enabling Changes to the Initialization Parameter Settings 

Preparing a Standby Database for Manual Recovery: Basic Tasks

Table 2-3 illustrates 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 Net8. If you do not wish to use Net8 to connect to the standby database, skip tasks 4 and 5.

Table 2-3  Task List: Preparing for Manual Recovery
  Task  Procedure 

Either make a new backup of the primary datafiles or access an old backup. 

Creating the Standby Datafiles 

Connect to the primary database and create the standby control file. 

Creating the Standby Control File 

Copy the backup datafiles and standby control file from the primary site to the standby site. 

Transferring Files to the Standby Site 

If you want to create a Net8 connection to the standby database, create a service name. 

Configuring the tnsnames.ora File on the Primary Site 

If you want to create a Net8 connection to the standby database, configure the listener on the standby site so that it can receive requests for connections to the standby instance. 

Configuring the listener.ora File on the Standby Site 

Create the standby initialization parameter file on the standby site and set the initialization parameters for the standby database. Optionally, set DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT to automatically rename primary files in the standby control file. 

Configuring the Standby Database Initialization Parameter File 

Start the standby instance and mount the standby database. 

Starting the Standby Instance 

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 DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT in step 6. If step 6 renamed all files, skip this step. 

Manually Renaming Standby Files Not Captured by Conversion Parameters 

Creating the Standby Database Files

You can create a standby database on the same host as your primary database or on a separate host. If you create your standby database on the same host, follow the creation procedure carefully when creating the standby database files so that you do not overwrite files on the primary database.

The creation of the standby database files occurs in three stages:

  1. Creating the Standby Datafiles

  2. Creating the Standby Control File

  3. Transferring Files to the Standby Site

Creating the Standby Datafiles

First, make backups of your primary database datafiles. You create the standby datafiles from these backups.

You can use any backup of the primary database so long as you have archived redo logs to completely recover the database. The backup can be old or new, consistent or inconsistent. Hot backups have the advantage of allowing you to keep the database open while performing the backup. Nevertheless, you may prefer to make a new closed, consistent backup to prevent the application of a large number of archived redo logs.

To make a consistent, whole database backup to serve as the basis for the standby database:

  1. Start a SQL*Plus session on your primary database and query the V$DATAFILE view to obtain a list of the primary datafiles. For example, enter:

    SQL> SELECT name FROM v$datafile;
    NAME 
    ----------------------------------------------------------------------------
    /oracle/dbs/tbs_01.f
    /oracle/dbs/tbs_02.f
    /oracle/dbs/tbs_03.f
    /oracle/dbs2/tbs_11.f 
    /oracle/dbs2/tbs_12.f
    /oracle/dbs3/tbs_21.f
    /oracle/dbs3/tbs_22.f 
    7 rows selected.
    
    
    
  2. Shut down the primary database cleanly:

    SQL> SHUTDOWN IMMEDIATE;
    
    
    
  3. Make a consistent backup of the datafiles from your primary database using an operating system utility. For example, to copy all of the datafiles into the /backup temporary directory, enter:

    % cp /oracle/dbs/*.f /backup
    % cp /oracle/dbs2/*.f /backup
    % cp /oracle/dbs3/*.f /backup
    
    
  4. Reopen the primary database. For example, enter:

    SQL> STARTUP pfile=initPROD1.ora;
    

    See Also:

    To learn how to make operating system backups, see the Oracle8i Backup and Recovery Guide

Creating the Standby Control File

After you have created the backups that will be used as the standby datafiles, you can create the standby database control file. The control file must have been created at a time later than the latest timestamp for the backup datafiles.


Note:

You cannot use a single control file for both the primary and standby databases. The standby instance is independent from the primary instance and so requires exclusive possession of its database files. 


To create the standby database control file:

  1. Ensure that the primary database is in ARCHIVELOG mode and that archiving is enabled. Either issue the ARCHIVE LOG LIST statement or query the V$DATABASE view:

    SQL> CONNECT sys/change_on_install@prod1
    SQL> ARCHIVE LOG LIST
    Database log mode              Archive Mode
    Automatic archival             Enabled
    Archive destination            /vobs/oracle/work/arc_dest/arc
    Oldest online log sequence     821
    Next log sequence to archive   822
    Current log sequence           822
    
    
  2. Connect to the primary database and create the control file for your standby database. For example, if you want to create the standby control file as oracle/dbs/stbycf.f on the primary site, enter the following:

    SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/oracle/dbs/stbycf.f';
    
    

    Note that the filename for the created standby control file must be different from the filename of the current control file of the primary database.

    See Also:

    For ALTER DATABASE syntax, see the Oracle8i SQL Reference

Transferring Files to the Standby Site

After you have successfully created the standby datafiles and control file, transfer the files to the standby site using an operating system utility. For example, if the standby site and primary site are on the same host, you can use the UNIX cp command to transfer files; if they are on separate hosts, you can use ftp.

If the standby database is on  Then you 

A separate host with the same directory structure as the primary database 

Can use the same path names for the standby files as the primary files. In this way, you do not have to rename the primary datafiles in the standby control file. 

The same host as the primary database, or the standby database is on a separate host with a different directory structure 

Must rename the primary datafiles in the standby control file after copying them to the standby site. You can:

 

To transfer datafiles and the control file to the standby site:

Transfer the created control file and datafile backups to the standby site using operating system commands or utilities. Use an appropriate method for transferring binary files.

  1. Transfer the control file first, because this transfer takes the least time. For example, enter the following:

    % cp /backup/db.cf /standby/oracle/dbs/db.cf
    
    
  2. Transfer the backup datafiles. For example, enter:

    % cp /backup/*.df /standby/oracle/dbs
    
    
  3. Transfer all available archived redo logs to the standby site. For example, enter:

    % cp /arc_dest/*.arc /standby/arc_dest
    

Configuring Network Files for Primary and Standby Databases

Network configuration varies greatly from system to system. If you do not plan to implement a managed standby environment in which the primary site archives to a standby site, you do not need Net8. You can connect to the standby database using operating system authentication. To implement a managed standby environment, however, you must create a service name for the standby instance. Consequently, you must use Net8.

In a managed standby environment, you must configure the listener.ora file for the standby site so that the standby site can receive archived logs from the primary site. If you do not use a name server, you will have to configure a tnsnames.ora file for the primary site. You may also have to configure additional network files such as SQL*Net.ora and names.ora. For an account of Net8 configuration, see the Net8 Administrator's Guide.

The information in the primary site tnsnames.ora file must correspond to the information in the standby site listener.ora file. The following table indicates which parameters must be identical and gives sample settings. Values that must be the same in both the tnsnames.ora and listener.ora files are in bold:

Value  Sample tnsnames.ora Setting  Sample listener.ora Setting 

PORT 

sbdb = (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp) (PORT=1512)(HOST=hst1)) (CONNECT_DATA = (SID=stby1))) 

LISTENER = (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp) (PORT=1512)(HOST=hst1))) 

HOST 

sbdb = (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp) (PORT=1512)(HOST=hst1)) (CONNECT_DATA = (SID=stby1))) 

LISTENER = (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp) (PORT=1512)(HOST=hst1))) 

SID (tnsnames) = SID_NAME (listener) 

sbdb = (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp) (PORT=1512)(HOST=hst)) (CONNECT_DATA = (SID=stby1))) 

SID_LIST_LISTENER = (SID_LIST= (SID_DESC= (SID_NAME=stby1)(ORACLE_HOME=/oracle))) 

PROTOCOL 

sbdb = (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp) (PORT=1512)(HOST=hst1)) (CONNECT_DATA = (SID=stby1))) 

LISTENER = (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp) (PORT=1512)(HOST=hst1))) 

KEY 

sbdb = (DESCRIPTION= (ADDRESS=(PROTOCOL=ipc) (KEY=foo))(CONNECT_DATA=(SID=stby1))) 

LISTENER = (ADDRESS_LIST= (ADDRESS = (PROTOCOL=ipc) (KEY=foo)))  

Following are generic procedures for modifying network files in a typical configuration. This section contains the following topics:

Configuring the tnsnames.ora File on the Primary Site

If you want to archive redo logs to a standby site, and you are not using an Oracle Names server, you must configure the tnsnames.ora file on the primary site. This file contains the service name of the standby instance.

To modify the tnsnames.ora file for a TCP connection:

  1. Start a text editor and open the tnsnames.ora file, which is typically located in $ORACLE_HOME/network/admin.

  2. Add the following entry to the tnsnames.ora file, substituting appropriate values for standby_service_name, port_number, host_name, and standby_sid. Make sure the SID matches the SID_NAME of the listener.ora file and the PORT values are the same in the two files:

    standby_service_name = (DESCRIPTION=
    		     				(ADDRESS=(PROTOCOL=tcp)(PORT=port_number)(HOST=host_name))
         (CONNECT_DATA=(SID=standby_sid))
    )
    
    

    For example, for standby database STANDBY1 on host REMOTE2 you can enter the following:

    standby1 = (DESCRIPTION=
    		     				(ADDRESS=(PROTOCOL=tcp)(PORT=1512)(HOST=remote2))
         (CONNECT_DATA=(SID=standby1))
    )
    
To modify the tnsnames.ora file for an IPC connection:

  1. Start a text editor and open the tnsnames.ora file, which is typically located in $ORACLE_HOME/network/admin.

  2. Add the following entry to the tnsnames.ora file, substituting appropriate values for standby_service_name, key_handle, and standby_sid. Make sure the SID matches the SID_NAME of the listener.ora file and the KEY values are the same in the two files:

    standby_service_name = (DESCRIPTION=
    		     				(ADDRESS=(PROTOCOL=ipc)(KEY=key_handle))
         (CONNECT_DATA=(SID=standby_sid))
    )
    
    

    For example, for standby database STANDBY1 you might enter the following:

    standby1 = (DESCRIPTION=
    		     				(ADDRESS=(PROTOCOL=ipc)(KEY=stby))
         (CONNECT_DATA=(SID=standby1))
    )
    

    See Also:

    For information about the tnsnames.ora file or network configuration parameters, see the Net8 Administrator's Guide

Configuring the listener.ora File on the Standby Site

In order to archive redo logs to a standby site, you must configure the listener.ora file on the standby site. The listener receives network connection requests from client applications and reroutes them to the standby server.

To modify the listener.ora file for a TCP connection:

  1. Start a text editor and open the listener.ora file, which is typically located in $ORACLE_HOME/network/admin.

  2. Add the listener to the file, substituting appropriate values for port_number and host_name. Note that you can create a new listener and call it anything you want, or add a new address to a previously existing listener:

    STANDBY_LISTENER = (ADDRESS_LIST=
     (ADDRESS=(PROTOCOL=tcp)(PORT=port_number)(HOST=host_name))
    )
    
    

    For example, for a standby host called REMOTE2 you might enter:

    STANDBY_LISTENER = (ADDRESS_LIST=
     (ADDRESS=(PROTOCOL=tcp)(PORT=1512)(HOST=remote2))
    )
    
    
  3. Add the following entry to the SID list for the listener, substituting appropriate values for standby_sid_name and oracle_home:

    SID_LIST_STANDBY_LISTENER = (SID_LIST=
     (SID_DESC=(SID_NAME=standby_sid_name)(ORACLE_HOME=/oracle_home))
    )
    
    

    For example, for a standby database called STANDBY1 you might enter:

    SID_LIST_STANDBY_LISTENER = (SID_LIST=
     (SID_DESC=(SID_NAME=standby1)(ORACLE_HOME=/oracle))
    )
    
    
  4. If the listener is already started, enter stop and then enter start. If it is not started, use an operating system command to start it. For example, on a UNIX system enter:

    % lsnrctl
    
    LSNRCTL for Solaris: Version 8.1.5.0.0 - Production on 23-MAR-99 12:04:10
    
    (c) Copyright 1998 Oracle Corporation.  All rights reserved.
    
    Welcome to LSNRCTL, type "help" for information.
    
    LSNRCTL> stop
    
    
  5. Ensure that the service is enabled by issuing the status command:

    LSNRCTL> status
    
    

    If the information for the standby service is configured correctly, you should see it among the list of the valid service names:

    standby1               has 1 service handler(s)
    
To modify the listener.ora file for an IPC connection:

  1. Start a text editor and open the listener.ora file, which is typically located in $ORACLE_HOME/network/admin.

  2. Add the listener to the file, substituting appropriate values for key_handle. Note that you can create a new listener and call it anything you want, or add a new address to a previously existing listener:

    STANDBY_LISTENER = (ADDRESS_LIST=  
       (ADDRESS = (PROTOCOL=ipc) (KEY=key_handle))
    )    
    
    

    For example, for a standby host called REMOTE2 you might enter:

    STANDBY_LISTENER = (ADDRESS_LIST=  
       (ADDRESS = (PROTOCOL=ipc) (KEY=stby))
    )    
    
    
  3. Add the following entry to the SID list for the listener, substituting appropriate values for standby_sid_name and oracle_home:

    SID_LIST_STANDBY_LISTENER = (SID_LIST=  
     (SID_DESC = (SID_NAME=standby_sid_name)(ORACLE_HOME=oracle_home))  
    )
    
    

    For example, for a standby database called STANDBY1 you might enter:

    SID_LIST_STANDBY_LISTENER = (SID_LIST=
     (SID_DESC = (SID_NAME=standby1)(ORACLE_HOME=/oracle))
    )
    
    
  4. If the listener is already started, enter stop and then enter start. If it is not started, use an operating system command to start it. For example, on a UNIX system enter:

    % lsnrctl
    
    LSNRCTL for Solaris: Version 8.1.5.0.0 - Production on 23-MAR-99 12:04:10
    
    (c) Copyright 1998 Oracle Corporation.  All rights reserved.
    
    Welcome to LSNRCTL, type "help" for information.
    
    LSNRCTL> stop
    
    
  5. Ensure that the service is enabled by issuing the status command:

    LSNRCTL> status
    
    

    If the information for the standby service is configured correctly, you should see it among the list of the valid service names:

    standby1               has 1 service handler(s)
    

Configuring the Primary Database Initialization Parameter File

If you do not plan to implement a managed standby environment, you should not have to change the initialization parameter file of the primary system at all. You must transfer and apply the archived redo logs to the standby database manually, so you do not need to alter the archiving destinations.

If you do plan to implement a managed standby environment, you need to add new archiving destinations to the initialization parameter file of the primary system. This section assumes that you plan to implement a managed standby environment.

For the primary database to archive to a local or remote standby database location, the following must be true:

This section contains these topics:

Specifying Archive Destinations

Specify up to five destinations for your primary database archived logs by setting the LOG_ARCHIVE_DEST_n initialization parameter (where n is an integer from 1 to 5). Each numerically suffixed parameter uniquely identifies an individual destination, as shown in the following example:

# first local archiving destination
LOG_ARCHIVE_DEST_1 = 'LOCATION=/oracle/arc/'   

# second local archiving destination
LOG_ARCHIVE_DEST_2 = 'LOCATION=/oracle/arc2/' 

# third standby archiving destination 
LOG_ARCHIVE_DEST_3 = 'SERVICE=stby'           

If you wish to archive redo logs to a standby database in managed recovery mode, you must use LOG_ARCHIVE_DEST_n in conjunction with the SERVICE keyword. Note that at least one archiving destination must be a local directory; that is, a non-standby site.

When using LOG_ARCHIVE_DEST_n, specify the archiving location using these keywords:

Keyword  Indicates  Example 

LOCATION 

A local directory 

LOG_ARCHIVE_DEST_1= 'LOCATION=/arc_dest/' 

SERVICE 

Archival through a Net8 service name 

LOG_ARCHIVE_DEST_2 = 'SERVICE=standby1' 

When using the LOCATION keyword, specify a valid path name for your operating system. When you specify SERVICE, Oracle translates the net service name through the tnsnames.ora file to a connect descriptor. The descriptor contains the information necessary for connecting to the standby database.

See Also:

For a detailed account of LOG_ARCHIVE_DEST_n and the archiving process, see the chapter on archived redo logs in the Oracle8i Administrator's Guide.  

Specifying Mandatory and Optional Archive Destinations

Using the LOG_ARCHIVE_DEST_n parameters, you can specify whether a destination has the attributes OPTIONAL (default) or MANDATORY. For example, you can set the parameter as follows:

LOG_ARCHIVE_DEST_3 = 'SERVICE=standby1 MANDATORY' 

Oracle Corporation recommends specifying the local directory destination as MANDATORY.

The LOG_ARCHIVE_MIN_SUCCEED_DEST=m parameter (where m is an integer from 1 to 5) specifies the number of destinations that must archive successfully before LGWR can overwrite the online redo logs. All MANDATORY destinations and non-standby OPTIONAL destinations contribute to satisfying the LOG_ARCHIVE_MIN_SUCCEED_DEST=m count. For example, you can set the parameter as follows:

LOG_ARCHIVE_MIN_SUCCEED_DEST = 2   # Oracle must archive to at least two 
                                   # locations before overwriting the online 
                                   # redo logs. 

See Also:

For a detailed account of the OPTIONAL and MANDATORY keywords, see the chapter on archived redo logs in the Oracle8i Administrator's Guide.  

Enabling Archive Destination States

The LOG_ARCHIVE_DEST_STATE_n (where n is an integer from 1 to 5) initialization parameter specifies the state of the destination specified by its corresponding LOG_ARCHIVE_DEST_n parameter (where n is the same integer). For example, the LOG_ARCHIVE_DEST_STATE_3 parameter specifies the state of the LOG_ARCHIVE_DEST_3 archiving destination.

The archiving destination parameters can have two values: ENABLE and DEFER. ENABLE indicates that Oracle can archive to the destination, whereas DEFER indicates that it should not.

For example, you can set the parameter as follows:

LOG_ARCHIVE_DEST_STATE_2 = ENABLE
LOG_ARCHIVE_DEST_2 = 'SERVICE=stby1'

See Also:

For a detailed account of the archive destination states, see the chapter on archived redo logs in the Oracle8i Administrator's Guide. For a description of the LOG_ARCHIVE_DEST_STATE_n parameter, see the Oracle8i Reference

Configuring Oracle to Re-Archive to a Failed Destination

Use the LOG_ARCHIVE_DEST_n parameters to determine whether and when the archiver process attempts to re-archive to a failed destination following an error. The REOPEN=s (where s is an integer) option specifies the minimum number of seconds before the archiver process should try to reaccess a failed destination. Note that REOPEN applies to all errors, not just OPEN errors.

If you specify REOPEN, the keyword has a default value of 300 seconds. If you do not specify REOPEN, it has the value of 0, which is the same as turning off the option. Note that if the REOPEN option is turned off, the archiver process will never attempt to reaccess a destination following an error.

You cannot use REOPEN to specify a limit on the number of attempts to reconnect and transfer archived logs. The REOPEN attempt either succeeds or fails, in which case the REOPEN information is reset. By default, the managed recovery operation waits indefinitely for a requested archived redo log; it terminates only through a CANCEL command, a shutdown, or a crash.

For example, you can set the parameter as follows to specify a reopen time of 60 seconds:

LOG_ARCHIVE_DEST_2 = 'SERVICE=standby2 OPTIONAL REOPEN=60' 

See Also:

For a detailed account of how to use the REOPEN option, see the chapter on archived redo logs in the Oracle8i Administrator's Guide.  

Configuring the Standby Database Initialization Parameter File

Once you have configured the primary database initialization parameter file, you can duplicate the file for use by the standby database. The procedure for creating the standby initialization parameter file is as follows:

  1. Copy the initialization parameter file for the primary database using an operating system utility.

  2. Edit the initialization parameter file for use by the standby database.

  3. Transfer the initialization parameter file to the standby site using an appropriate operating system utility.

This section contains the following topics:

Configuring Standby Initialization Parameters: General Considerations

As a rule, most initialization parameters at the primary and standby databases should be identical, although some initialization parameters such as CONTROL_FILES and DB_FILE_NAME_CONVERT need to be changed. Differences in initialization parameters other than those described in the following table can cause performance degradation at the standby database and, in some cases, halt standby database operations. Only change parameter values when required for the functioning of the standby database or for filename conversions.

The initialization parameters in Table 2-4 play a key role in the configuration of the standby database.

Table 2-4  Configuring Standby Database Initialization Parameters
Parameter  Guideline 

COMPATIBLE 

Always set the same at the primary and standby databases. If different, you may not be able to apply the logs from your primary database to the standby database. 

DB_NAME 

Always set to the same value as DB_NAME value in the primary database. 

CONTROL_FILES 

Always set to a different value from CONTROL_FILES in primary database. The names of the control files for the standby database must exist at the standby site. 

DB_FILE_NAME_CONVERT 

Set to distinguish standby datafile filenames from primary datafile filenames, for example, when both databases reside on the same host, or a separate standby host uses different path names from the primary host. Because the standby control file is a copy of the primary control file, you must convert the standby filenames if the standby database is on the same host as the primary database or on a separate host with different path names. See also Renaming Primary Filenames in the Standby Control File

LOCK_NAME_SPACE  

Always set this value when the standby and primary databases share a host. Specifies the name space that the distributed lock manager uses to create lock names.  

LOG_ARCHIVE_DEST 

Specifies the location of the archived logs for a standby database in manual recovery mode. When performing manual recovery on the standby database, Oracle relies on either LOG_ARCHIVE_DEST or a user-defined filename to locate the logs.

This parameter is also relevant for managed recovery. If a log is missing at the standby site and managed recovery halts, you must issue RECOVER STANDBY DATABASE to initiate manual recovery, which causes Oracle to look in LOG_ARCHIVE_DEST for the logs by default. Typically, you set STANDBY_ARCHIVE_DEST and LOG_ARCHIVE_DEST to the same value for managed recovery. 

LOG_ARCHIVE_TRACE 

Optionally, set this parameter to an integer value to see the progression of the archiving of redo logs to the standby site. Oracle writes an audit trail of the archived logs received from the primary database into a trace file. The parameter controls output generated by the archiving process (ARCn and foreground processes) on the primary database and the RFS process of the standby database. For a description of the possible integer values for this parameter and their meanings, see Determining Which Archived Logs Have Been Received by the Standby Site

LOG_FILE_NAME_CONVERT 

Set to make your standby redo log filenames distinguishable from primary database redo log filenames. The parameter value converts the filename of a new log file on the primary database to the filename of a log file on the standby database. Adding a log file to the primary database necessitates adding a corresponding file to the standby database. When the standby database is updated, this parameter is used to convert the log file name on the primary database to the log file name on the standby database. The file must exist and be writable on the standby database or the recovery process will halt with an error.  

STANDBY_ARCHIVE_DEST 

Used solely by a standby database in managed recovery mode to determine the location for the archived logs received from the primary database. Managed recovery mode uses this value along with LOG_ARCHIVE_FORMAT to generate the fully qualified standby database log filenames and stores the filenames in the standby control file. Managed recovery uses this data to drive recovery.

For managed recovery, set STANDBY_ARCHIVE_DEST and LOG_ARCHIVE_DEST to the same value. If manual recovery is required because of a gap sequence, copy the missing log to the same location as the other logs and recover manually. You can then place the standby database back into managed recovery mode. 

See Also:

For more information on these initialization parameters, see the Oracle8i Reference

Renaming Primary Filenames in the Standby Control File

If the standby site uses the same directory structure as the primary site, then you do not have to rename the primary filenames in the standby control file. If the primary and standby databases occupy the same node, however, or if the primary and standby sites use different directory structures, then you must rename the primary files in the standby control file so that the archived logs can be applied to the standby datafiles.

You can set initialization parameters so that your standby database automatically converts datafile and archived redo log filenames based on data in the standby database control file. If you cannot rename all primary filenames automatically using these parameters, then you must rename them manually (see Manually Renaming Standby Files Not Captured by Conversion Parameters).


Note:

Note that if you do not set the LOCK_NAME_SPACE parameters differently when the standby and primary databases share a node, you will receive an ORA-1102 error. 


The initialization parameters in Table 2-5 perform automatic filename conversions.

Table 2-5  Filename Conversion
Parameter  Function 

DB_FILE_NAME_CONVERT 

Converts primary database datafile filenames to standby datafile filenames, for example, from tbs_* to standbytbs_*

LOG_FILE_NAME_CONVERT  

Converts primary database redo log filenames to standby database redo log filenames, for example, from log_* to standbylog_*

Use DB_FILE_NAME_CONVERT to convert the filename of a datafile on the primary database to a filename on the standby database; use LOG_FILE_NAME_CONVERT to convert the filename of a new redo log on the primary database to a filename on the standby database. Adding a datafile or log to the primary database necessitates adding a corresponding file to the standby database.

When the standby database is updated, DB_FILE_NAME_CONVERT is used to convert the datafile name on the primary database to a datafile name on the standby database. The file must exist and be writable on the standby database or the recovery process will halt with an error.

The DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT parameters must have two strings. The first string is a sequence of characters to be looked for in a primary database filename. If that sequence of characters is matched, it is replaced by the second string to construct the standby database filename.

Figure 2-1 shows how the filename conversion parameters work.

Figure 2-1 Setting Filename Conversion Parameters


Text description of sbr81017.gif follows.

Text description of the illustration sbr81017.gif.

If you execute the following statements, then the conversion parameters do not apply to the affected files:

Specifying Filenames for the Standby Database Archived Redo Logs

The naming conventions for archived redo logs on the standby site depend on whether the standby database is part of a managed standby environment. This section contains the following topics:

Specifying Log Filenames for Managed Recovery

When in a managed standby environment, the standby database uses the STANDBY_ARCHIVE_DEST parameter in the standby initialization parameter file to determine the directory in which to store the archived redo logs. Oracle uses this value in conjunction with LOG_ARCHIVE_FORMAT to generate the archived log filenames on the standby site.

Parameter  Indicates  Example 

STANDBY_ARCHIVE_DEST 

Directory in which to place logs 

STANDBY_ARCHIVE_DEST= /arc_dest/ 

LOG_ARCHIVE_FORMAT 

Format for filenames of logs 

LOG_ARCHIVE_FORMAT = "log_%t_%s.arc"

Note: The %s corresponds to the sequence number. The %t, which is required for OPS configurations, corresponds to the thread. 

Oracle stores the fully qualified filenames in the standby control file. Managed recovery uses this information to perform the recovery operation. Access this information through the V$ARCHIVED_LOG view:

SQL> SELECT name FROM v$archived_log;
NAME                                                                            
--------------------------------------------------------------------------------
/arc_dest/log_1_771.arc                                       
/arc_dest/log_1_772.arc                                       
/arc_dest/log_1_773.arc                                       
/arc_dest/log_1_774.arc                                       
/arc_dest/log_1_775.arc

Specifying Log Filenames for Manual Recovery

With the exception of RECOVER MANAGED STANDBY DATABASE, the RECOVER STANDBY DATABASE statements rely on one of the following to provide the location of the archived files:

Even if you run a standby database in managed recovery mode, manual recovery may sometimes be necessary; for example, when an archived redo log is absent from the standby site. This situation can occur when a network error prevents one or more archived redo logs from being transferred by the primary database.

Issuing the RECOVER STANDBY DATABASE statement manually in these circumstances requires you to use the LOG_ARCHIVE_DEST parameter to locate the necessary archived redo log. For a standby database that is normally in managed recovery mode, Oracle Corporation recommends setting STANDBY_ARCHIVE_DEST and LOG_ARCHIVE_DEST to the same value. In this way, a standby database can access the same set of archived redo logs whether in managed or manual recovery mode.

Configuring the Standby Initialization Parameter File: Typical Settings

How you configure the initialization parameter file for the standby database depends on several interrelated factors:

Table 2-6 illustrates which parameters you should set depending on the standby database configuration.

Table 2-6  Setting Standby Database Initialization Parameters
Standby Host  Directory Structure  Recovery Mode  Standby Initialization Parameters 

Same as primary host 

Different from primary host 

Manual 

COMPATIBLE

CONTROL_FILES

DB_FILE_NAME_CONVERT

LOCK_NAME_SPACE

LOG_ARCHIVE_DEST

LOG_ARCHIVE_TRACE

LOG_FILE_NAME_CONVERT 

Same as primary host 

Different from primary host 

Managed 

Same as for manual recovery, except set STANDBY_ARCHIVE_DEST to the same value as LOG_ARCHIVE_DEST 

Separate from primary host 

Same as primary host 

Manual 

COMPATIBLE

CONTROL_FILES

LOG_ARCHIVE_DEST

LOG_ARCHIVE_TRACE 

Separate from primary host 

Same as primary host 

Managed 

Same as for manual recovery, except set STANDBY_ARCHIVE_DEST to the same value as LOG_ARCHIVE_DEST 

Separate from primary host 

Different from primary host 

Manual 

COMPATIBLE

CONTROL_FILES

DB_FILE_NAME_CONVERT

LOG_ARCHIVE_DEST

LOG_ARCHIVE_TRACE

LOG_FILE_NAME_CONVERT 

Separate from primary host 

Different from primary host 

Managed 

Same as for manual recovery, except set STANDBY_ARCHIVE_DEST to the same value as LOG_ARCHIVE_DEST 

Example: Managed Standby Database on Same Host as Primary Database

Following are some sample initialization parameter settings for a managed standby database that resides on the same host as primary database PROD1.

COMPATIBLE = 8.1.6
CONTROL_FILES = /oracle/work/standby/dbs/cf1.f
DB_FILE_NAME_CONVERT = /oracle/dbs/tbs, /oracle/work/standby/dbs/standby
DB_NAME = prod1
LOCK_NAME_SPACE = stby  # required for a standby on the same host as the primary
LOG_ARCHIVE_DEST = /oracle/work/standby/dbs/arc/
LOG_ARCHIVE_FORMAT = arc_%t_%s.ar
LOG_ARCHIVE_TRACE = 8
LOG_FILE_NAME_CONVERT = /oracle/dbs/t1, /oracle/work/standby/dbs/standby_t1
STANDBY_ARCHIVE_DEST = /oracle/work/standby/dbs/arc/
Example: Managed Standby Database on Different Host from Primary Database

Following are some sample initialization parameter settings for a managed standby database that resides on a different host from primary database PROD1, but uses the same directory structure.

COMPATIBLE = 8.1.6
CONTROL_FILES = /oracle/work/standby/dbs/cf1.f
DB_NAME = prod1
LOG_ARCHIVE_DEST = /oracle/work/standby/arc_dest/
LOG_ARCHIVE_FORMAT = arc_%t_%s.ar
LOG_ARCHIVE_TRACE = 6
STANDBY_ARCHIVE_DEST = /oracle/work/standby/arc_dest/
Example: Manual Standby Database on Different Host from Primary Database

Following are some sample initialization parameter settings for a standby database in manual recovery mode that resides on a different host from primary database PROD1, and also uses a different directory structure.

COMPATIBLE = 8.1.6
CONTROL_FILES = /oracle/work/standby/cf1.f
DB_FILE_NAME_CONVERT = /oracle, /oracle/work/standby
DB_NAME = prod1
LOG_ARCHIVE_DEST = /oracle/work/arc_dest/
LOG_ARCHIVE_FORMAT = arc_%t_%s.ar
LOG_ARCHIVE_TRACE = 34
LOG_FILE_NAME_CONVERT = /oracle/dbs/t1, /oracle/work/standby/dbs/standby_t1

Configuring Parameter and Network Files: Scenario

This scenario assumes the following:

Settings for PROD1 Initialization Parameter File

Following are sample settings for LOG_ARCHIVE_DEST_1, LOG_ARCHIVE_DEST_2, LOG_ARCHIVE_DEST_3, and LOG_ARCHIVE_DEST_4 in the initialization parameter file for the primary database PROD1:

# This example specifies a local archiving destination and enables the 
# destination. 

LOG_ARCHIVE_DEST_1 = 'LOCATION=/arc_dest/' 
LOG_ARCHIVE_DEST_STATE_1 = ENABLE

# This example specifies net service name "standby1", makes archiving mandatory, 
# and enables the destination. 

# A REOPEN value of 5 indicates that if the LOG_ARCHIVE_DEST_2 location
# encounters an error during archival of a redo log file, the destination 
# remains inactive until the archival of a redo file is about to begin and 5 
# seconds has elapsed. At that time, Oracle again attempts the archival to LOG_
# ARCHIVE_DEST_2. 
  
# If Oracle encounters an error when archiving to a mandatory destination, the 
# destination is inactive for the duration of the archival of the current redo 
# log file. The destination may be reactivated (based on the REOPEN attribute) 
# at the start of the archival of another redo log.  

LOG_ARCHIVE_DEST_2 = 'SERVICE=standby1 MANDATORY REOPEN=5' 
LOG_ARCHIVE_DEST_STATE_2 = ENABLE

# Specifies net service name "standby2", makes archiving optional, and makes 
# Oracle retry archiving after 5 seconds should an error occur. The destination 
# is enabled.

LOG_ARCHIVE_DEST_3 = 'SERVICE=standby2 OPTIONAL REOPEN=5' 
LOG_ARCHIVE_DEST_STATE_3 = ENABLE 

# Specifies net service name "standby3", makes archiving optional, and makes
# Oracle retry archiving after 60 seconds should an error occur. The 
# destination is deferred, however, which means that Oracle has currently 
# disabled archiving to this destination.

LOG_ARCHIVE_DEST_4 = 'SERVICE=standby3 OPTIONAL REOPEN=60' 
LOG_ARCHIVE_DEST_STATE_4 = DEFER 
TNS Settings

Following are settings in the primary host tnsnames.ora file for connecting to the standby databases STANDBY1, STANDBY2, and STANDBY3 in the preceding example:

# The standby1 database is on the same node as the primary database. Connection 
# is made through the IPC protocol.
standby1 = (DESCRIPTION= 
             (ADDRESS= 
                (PROTOCOL=ipc) 
                (KEY=local_standby)) 
             (CONNECT_DATA= 
                (SID=stby1) 
                (SERVER=DEDICATED))) 
 
# The standby2 database is on a different node from the primary database. 
# Connection is made through the TCP protocol.
standby2 = (DESCRIPTION= 
             (ADDRESS= 
                (PROTOCOL=tcp) 
                (HOST=remote2) 
                (PORT=1512))
             (CONNECT_DATA= 
                (SID=stby2) 
                (GLOBAL_NAME=standby2) 
                (SERVER=DEDICATED)))

# The standby3 database is on a different node from the primary database. 
# Connection is made through the TCP protocol.
standby3 = (DESCRIPTION= 
             (ADDRESS= 
                (PROTOCOL=tcp) 
                (HOST=remote3) 
                (PORT=1523))
             (CONNECT_DATA= 
                (SID=stby3) 
                (GLOBAL_NAME=standby3) 
                (SERVER=DEDICATED)))
Listener Settings

Following are the settings in the listener.ora files for the standby databases STANDBY1, STANDBY2, and STANDBY3:

# The listener settings for standby1 on host local
LISTENER = (ADDRESS_LIST=  
   (ADDRESS= 
   (PROTOCOL=ipc) 
   (KEY=local_standby)))   
 
SID_LIST_LISTENER = (SID_LIST=  
 (SID_DESC=(SID_NAME=stby1)(ORACLE_HOME=/oracle))  
  
# The listener settings for standby2 on the remote host remote2 
LISTENER = (ADDRESS_LIST=  
 (ADDRESS= 
   (PROTOCOL=tcp) 
   (HOST=remote2) 
   (PORT=1512))) 
 
SID_LIST_LISTENER = (SID_LIST= 
 (SID_DESC=(SID_NAME=stby2)(ORACLE_HOME=/oracle))

# The listener settings for standby3 on the remote host remote3
LISTENER = (ADDRESS_LIST=  
 (ADDRESS= 
   (PROTOCOL=tcp) 
   (HOST=remote3) 
   (PORT=1523))) 
 
SID_LIST_LISTENER = (SID_LIST= 
 (SID_DESC=(SID_NAME=stby3)(ORACLE_HOME=/fs3/oracle))
Settings for STANDBY1, STANDBY2, and STANDBY3 Initialization Parameter Files

Following are settings in the initialization parameter files for the standby databases STANDBY1, STANDBY2, and STANDBY3 in the preceding example. These settings determine the filenames on the standby database for the archived redo logs:

# The init.ora values for the standby1 database, which is on the same host as 
# the primary database
STANDBY_ARCHIVE_DEST = /oracle/standby/arc/
LOG_ARCHIVE_DEST = /oracle/standby/arc/ # the location is the same as 
                                        # STANDBY_ARCHIVE_DEST
LOG_ARCHIVE_FORMAT = log%t_%s.arc
LOG_ARCHIVE_TRACE = 16
LOCK_NAME_SPACE = foo_bar
DB_FILE_NAME_CONVERT = /oracle/dbs, /oracle/standby/dbs
LOG_FILE_NAME_CONVERT = /oracle/dbs, /oracle/standby/dbs

# The init.ora values for the standby2 database, which is on 
# host remote2. Host remote2 uses the same directory structure as host local.
STANDBY_ARCHIVE_DEST = /oracle/standby/arc/
LOG_ARCHIVE_DEST = /oracle/standby/arc/ # the location is the same as 
                                        # STANDBY_ARCHIVE_DEST
LOG_ARCHIVE_FORMAT = log%t_%s.arc
LOG_ARCHIVE_TRACE = 16

# The init.ora values for the standby3 database, which is on host remote3. Host 
# remote3 uses a different directory structure from host local.
STANDBY_ARCHIVE_DEST = /fs3/arc_dest/
LOG_ARCHIVE_DEST = /fs3/arc_dest/   # the location is the same as 
                                    # STANDBY_ARCHIVE_DEST
LOG_ARCHIVE_FORMAT = log%t_%s.arc
DBS_FILE_NAME_CONVERT = /oracle, /fs3/oracle
LOG_FILE_NAME_CONVERT = /oracle, /fs3/oracle

Starting the Standby Instance in Preparation for Recovery

The final stage of standby database preparation is starting the standby database instance so you can begin manual or managed recovery. This stage involves three tasks:

  1. Starting the Standby Instance

  2. Manually Renaming Standby Files Not Captured by Conversion Parameters

  3. Enabling Changes to the Initialization Parameter Settings

Starting the Standby Instance

After all necessary parameter and network files have been configured, you can start the standby instance. Note that if the instance is not started, the standby database cannot receive archived redo logs that are automatically transmitted to the standby site by the primary database.

To start the standby instance:

  1. Use SQL*Plus to connect to the standby database instance. For example, enter:

    SQL> CONNECT sys/change_on_install@standby1
    
    
  2. Start the Oracle instance at the standby database without mounting the database. For example, enter:

    SQL> STARTUP NOMOUNT pfile=initSTANDBY.ora;
    
    
  3. Mount the standby database:

    SQL> ALTER DATABASE MOUNT STANDBY DATABASE;
    

Manually Renaming Standby Files Not Captured by Conversion Parameters

Sometimes all of the primary datafiles and redo log files 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 

/oracle/dbs/df1.f 

/standby/df1.f 

/oracle/dbs/df2.f 

/standby/df2.f 

/data/df3.f 

/standby/df3.f 

You can set DB_FILE_NAME_CONVERT as follows to convert the filenames for the first two datafiles:

DB_FILE_NAME_CONVERT = '/oracle/dbs', '/standby'

Nevertheless, this parameter will not capture the renaming of /data/df3.f. You must rename this datafile manually in the standby database control file by issuing a SQL statement as follows:

SQL> ALTER DATABASE RENAME FILE '/data/df3.f' to '/standby/df3.f';
To rename a datafile manually:

  1. Using SQL*Plus, start the standby instance (if it is not already started) and then mount the database:

    SQL> STARTUP NOMOUNT pfile=initSTANDBY1.ora;
    SQL> ALTER DATABASE MOUNT STANDBY DATABASE;
    
    
  2. Issue an ALTER DATABASE statement for each datafile requiring renaming, where old_name is the old name of the datafile as recorded in the control file and new_name is the new name of the datafile that will be recorded in the standby control file:

    SQL> ALTER DATABASE RENAME FILE 'old_name' TO 'new_name';
    
    

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.

Enabling Changes to the Initialization Parameter Settings

If you configured the primary initialization parameter file to archive to the standby site, you should enable these new parameter settings after starting the standby instance and the listener on the standby site.

You can make changes to the primary database initialization parameter file while the database is open, but the changes only take effect when the instance is restarted. If the database is open and you want to avoid restarting it, enable the parameter changes dynamically using ALTER SYSTEM statements.

For example, assume that you made the following changes to the initialization parameter file while the database was open:

LOG_ARCHIVE_DEST_1="LOCATION=/arc_dest/ MANDATORY REOPEN=2";
LOG_ARCHIVE_DEST_2="SERVICE=stby1 MANDATORY REOPEN=2";
LOG_ARCHIVE_DEST_STATE_1=ENABLE;
LOG_ARCHIVE_DEST_STATE_2=ENABLE;
LOG_ARCHIVE_MIN_SUCCEED_DEST=2;

You can then connect to the primary database using SQL*Plus and issue ALTER SYSTEM statements as follows to enable these settings:

ALTER SYSTEM SET LOG_ARCHIVE_DEST_1="LOCATION=/arc_dest/ MANDATORY REOPEN=2";
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2="SERVICE=stby1 MANDATORY REOPEN=2';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;
ALTER SYSTEM SET LOG_ARCHIVE_MIN_SUCCEED_DEST=2;

Once you have enabled these changes, the primary database can start archiving redo logs to a standby database.

Troubleshooting the Standby Database Configuration

If you encounter a problem during standby database preparation, it will probably be one of the following:

The Standby Site Does Not Receive Logs Archived by the Primary Database

If the standby site is not receiving the logs, the first thing you should do is obtain information about the archiving status of the primary database by querying the V$ARCHIVE_DEST view. Check especially for error messages. For example, enter:

SQL> SELECT dest_id "ID",
  2> status "DB_status",
  3> destination "Archive_dest",
  4> error "Error"
  5> FROM v$archive_dest;

ID DB_status Archive_dest                   Error   
-- --------- ------------------------------ 
--------------------------------------
 1  VALID     /vobs/oracle/work/arc_dest/arc                          
 2  ERROR     standby1          ORA-16012: Archivelog standby database 
identifier mismatch  
 3  INACTIVE                            
 4  INACTIVE                    
 5  INACTIVE                                           
5 rows selected.

If the output of the query does not help you, check the following list of possible issues. If any of the following conditions is not met, the primary database will fail to archive to the standby site:

You Cannot Mount the Standby Database

If any of the following conditions is not met, you cannot mount the standby database:


Go to previous page Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index