Creating a Physical Standby Database __________________________________________ # Preparing the Primary Database for Standby Database Creation # Step-by-Step

Instructions for Creating a Physical Standby Database # Post-Creation Steps (configure the standby database for maximum performance mode, which is the default data protection mode.) ________________________________________________________________________________ _______________________________ ================================================================= #1. Preparing the Primary Database for Standby Database Creation ================================================================= 1.1 1.2 1.3 1.4 1.5 Enable Forced Logging Create a Password File Configure a Standby Redo Log Set Primary Database Initialization Parameters Enable Archiving

1.1 Enable Forced Logging ------------------------Force logging forces everything to be logged so that a standby will always be in sync with the primary without having to manually copy things across. SQL> ALTER DATABASE FORCE LOGGING; 1.2 Create a Password File -------------------------Every database in a Data Guard configuration must use a password file, and the password for the SYS user must b e identical on every system for redo data transmission to succeed. 1.3 Configure a Standby Redo Log -------------------------------A standby redo log is required for the maximum protection and maximum availabili ty modes and the LGWR ASYNC transport mode is recommended for all databases. Data Guard can recover and apply more redo data from a standby redo log than fro m archived redo log files alone. You should plan the standby redo log configuration and create all required log g roups and group members when you create the standby database. For increased avai lability,consider multiplexing the standby redo log files, similar to the way th at online redo log files are multiplexed. Perform the following steps to configure the standby redo log. Step 1 Ensure log file sizes are identical on the primary and standby databases. The size of the current standby redo log files must exactly match the size of th e current primary database online redo log files. For example, if the primary database uses two online redo log groups whose log files are 200K, then the st

For example. Example 3 1 Adding a Standby Redo Log File Group to a Specific Thread The following statement adds a new standby redo log file group to a standby db a nd assigns it to THREAD 5: SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 5 ('/oracle/dbs/log1c.rdo') SIZE 500M. you must have the ALTER DATABASE system privilege. Data Guard will automatically as sign standby redo log file groups to threads at runtime as they are needed by the various RAC instances. . then 6 standby eded on the standby database. the standby redo log files may not be archived as quickly as the online redo l og files. Verify the values used for the MAXLOGFILES and MAXLOGMEMBERS clauses on the SQL CREATE DATABASE statement will not limit the number of standby redo log file g roups and members that you can add. the recommended number of standby redo log file groups is dependent on the number of threads on the primary database. However.'/orac le/dbs/log2c. Use the following equation to determine an appropriate number of standby redo lo g file groups: (maximum number of logfiles for each thread + 1) * maximum number of threads Using this equation reduces the likelihood that the (LGWR) process will be blocked because a standby ocated on the standby database. This is because logical stan dby databases also write to online redo log files. The THREAD clause is required only if you want to add one or more standby redo l og file groups to a specific primary database thread. Step 2 Determine the appropriate number of standby redo log file groups. The standby database begins using the newly created standby redo data the next time there is a log switch on the primary database. if the files for each thread and 2 threads. If you do not include the THREAD clause and the configuration uses (RAC). Example 3 1 and Example 3 2 show how to create a new standby redo log file group usi ng the ALTER DATABASE statement with variations of the ADD STANDBY LOGFILE GROUP clause. Step 3 Verify related database parameters and settings. which take precedence over standby redo log files.andby redo log groups should also have log file sizes of 200K. Step 4 Create standby redo log file groups. the configuration should have one more standby redo log file group th an the number of online redo log file groups on the primary database. primary instance s log writer redo log file cannot be all primary database has 2 log redo log file groups are ne Note: Logical standby databases may require more standby redo log files (or addi tional ARCn processes) depending on the workload. To create new standby redo log file groups and members.rdo'. Thus. Minimally. The only way to override the limits specified by the MAXLOGFILES and MAXLOGMEMB ERS clauses is to re-create the primary database or control file.

Consider using Oracle Enterpris e Manager to automatically configure standby redo log on both your primary and standby databases. 30. Do not skip log file group numbers (that is. Note: Although the standby redo log is only used when the database is running in the standby role. Step 5 Verify the standby redo log file groups were created.4 Set Primary Database Initialization Parameters -------------------------------------------------On the primary database. and then query either the V$STANDBY_L OG view or the V$LOGFILE view on the standby database once it has been created. 20. Using group numbers can make administering standby redo log file groups easier. The configuration examples use the names shown in the following table: Database DB_UNIQUE_NAME Oracle Net Service Name . Example 3 3 -->> primary role initialization parameters that you maintain on the p rimary database. you define initialization parameters that control redo transport services while the database is in the primary role. the group number must be between 1 and the value of the MAXLOGFILES cla use. do not number groups 10.'/orac le/dbs/log2c.ARCHIVED. However.STATUS FROM V$STANDBY_LOG. SQL> SELECT GROUP#. or you will use additional space in the standby database control file.THREAD#. Oracle recommends that you create a standby redo log on the primary databa se so that the primary database can switch over quickly to the standby role without the n eed for additional DBA intervention.Example 3 2 Adding a Standby Redo Log File Group to a Specific Group Number You can also specify a number that identifies the group using the GROUP clause: SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 10 ('/oracle/dbs/log1c.rdo') SIZE 500M.rdo'.SEQUENCE#. an d so on). in voke a log switch on the primary database. This example -->> primary Chicago and physical standby db Boston. To verify the standby redo log file groups are created and running correctly. There are additionalparameters you need to add that control the receipt of the r edo data and log apply services when the primary database is transitioned to the standby role. GROUP# THREAD# SEQUENCE# ARC STATUS 3 1 16 NO ACTIVE 4 0 0 YES UNASSIGNED 5 0 0 YES UNASSIGNED 1. The parameters shown in Example 3 3 are valid for the Chicago database when it is running in either the primary or the standby database role.

boston)' *CONTROL_FILES='/arch1/chicago/control1. '/arch2/chicago/control2. stays with the database and .'chicago' *LOG_FILE_NAME_CONVERT= '/arch1/boston/'. Example 3 4 Primary Database: Standby Role Initialization Parameters *FAL_SERVER=boston *FAL_CLIENT=chicago *DB_FILE_NAME_CONVERT='boston'. and archives the incoming redo data when this database is i n the standby role. With the initialization parameters for both the primary and standby roles set as described. none of the parameters need to change after a role transition.Primary Physical standby chicago boston chicago boston Example 3 3 Primary Database: Primary Role Initialization Parameters *DB_NAME=chicago *DB_UNIQUE_NAME=chicago *LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago. DB_UNIQUE_NAME Recommended Setting an 8-character name.'/arch2/boston/'.'/arch2/chicago/' *STANDBY_FILE_MANAGEMENT=AUTO Specifying the initialization parameters shown in Example 3 4 sets up the primary database to resolve gaps. converts new datafile and log file path names from a n ew primary database.ALL_ROLES) DB_UNIQUE_NAME=chicago' *LOG_ARCHIVE_DEST_2= 'SERVICE=boston LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES.PRIMARY_ROLE) DB_UNIQUE_NAME=boston' *LOG_ARCHIVE_DEST_STATE_1=ENABLE *LOG_ARCHIVE_DEST_STATE_2=ENABLE *REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE *LOG_ARCHIVE_FORMAT=%t_%s_%r.ctl'.arc *LOG_ARCHIVE_MAX_PROCESSES=30 These parameters control how redo transport services transmit redo data to the standby system and the archiving of redo data on the local file system. Example 3 4 -->> additional standby role initialization parameters on the primary database. These parameters take effect when the primary database is transitioned to the st andby role.ctl' *LOG_ARCHIVE_DEST_1= 'LOCATION=/arch1/chicago/ VALID_FOR=(ALL_LOGFILES.'/arch1/chicago/'. Parameter DB_NAME ases. Use the same name for all standby datab a unique name for each database. Brief explanation about each parameter setting shown in Example 3 3 and Example 3 4.

In Example 3 3: # LOG_ARCHIVE_DEST_1 archives redo data generated by the pr imary database from the local online redo log files to the local archived redo log files in /arch1/chicago/. 1 for another example. you may need to specify these settings again using the SEND. RECEIVE. this enables the dynamic addition of a standby database to a Data Guard configuration that has a RAC primary database r unning in either maximum protection or maximum availability mode. ) LOG_ARCHIVE_FORMAT Specify the format for the archived redo log files u sing a thread (%t). LOG_ARCHIVE_MAX_PROCESSES = integer Specify the maximum number (from 1 to 30) of archiver (ARCn) processes you want Oracle software to invoke initially. Th e default value is 4. Data Guard automatically uses the LOG_ARCHIVE_D EST_10 initialization parameter as the default destination for local archiving. and resetlogs ID (%r). LOG_ARCHIVE_DEST_STATE_n smit redo data to the REMOTE_LOGIN_PASSWORDFILE d standby databases. Specify the path name for the control files on the primary d LOG_ARCHIVE_DEST_n Specify where the redo data is to be archived on the primary and standby systems. after a role transition. D. even if the s reverse roles. Thi s destination transmits redo data to the remote physical s tandby destination boston. See Section 5. However. the only user he password file is SYS. . NOSEND.does not change. # LOG_ARCHIVE_DEST_2 is valid only for the primary role.7. CONTROL_FILES atabase. or NORECEIVE keywords. sequence number (%s). Set the same password for SYS on both the primary an The recommended setting is either EXCLUSIVE or SHARE EXCLUSIVE The password file can be used by only one database and the password file can conta in names other than SYS. primary and standby database LOG_ARCHIVE_CONFIG Specify the DG_CONFIG attribute on this parameter to list th e DB_UNIQUE_NAME of the primary and standby databases in the Data Guard configuration. the LOG_ARCHIVE_CONFIG parameter enables the dat abase to send and receive redo. By default. ile. (SHARED More than one database can use a password f recognized by t ENABLE -->> to allow redo transport services to tran specified destination. Note: If a flash recovery area was configured (with the DB_RE COVERY_FILE_DEST initialization parameter) and you have not explicitly configured a local archiving destination with the LOCATION attribute.

ALTER DATABASE OPEN. it uses the Boston database as the FAL server from which to fetch (request) miss ing archived redo log files if Boston is unable to autom atically send the missing log files. then this parameter is required. ________________________________________________________________________________ _______________________________ ======================================================================= #2. Note that this parameter is used only to convert path names for physical standby databases. The FAL server (Boston) copies missing archived redo log fi les to the Chicago standby database. This p arameter converts the path names of the primary database datafiles to the standby datafile path names. Reference Database Task . Wh en the Chicago database is running in the standby role.5 Enable Archiving -------------------If archiving is not enabled. DB_FILE_NAME_CONVERT the path name and filename location of the primary datab ase datafiles followed by the standby location. Step-by-Step Instructions for Creating a Physical Standby Database ======================================================================= Checklist of the tasks that you perform to create a physical standby database an d the database or databases on which you perform each task. corresponding changes are made automatically to the standby database. put the primary database in ARCHIVELOG mode and ena ble automatic archiving: SQL> SQL> SQL> SQL> SHUTDOWN IMMEDIATE. 1. FAL_CLIENT the Oracle Net service name of the Chicago database. Multiple pairs of paths may be specified by this parameter. If the standby database is on the same system as the primary database or if the directory structure where the datafiles are located on the stand by site is different from the primary site. LOG_FILE_NAME_CONVERT //ly for online redo log files STANDBY_FILE_MANAGEMENT AUTO -->> so when datafiles are added to or dropped fro m the primary database. ALTER DATABASE ARCHIVELOG. STARTUP MOUNT.FAL_SERVER the Oracle Net service name of the FAL server (typically this is the database running in the primary role).

For example: SQL> CREATE PFILE='/tmp/initboston. Then.5 Standby 2.1 Primary 2. Create a text initialization parameter file (PFILE) from the server paramete r file (SPFILE) used by the primary database.ora' FROM SPFILE.ctl'. Oracle recommends that you use RMAN. in Section 2. as shown in the following example: SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/tmp/boston.7 Standby Create a Backup Copy of the Primary Database Datafiles Create a Control File for the Standby Database Prepare an Initialization Parameter File for the Standby Database Copy Files from the Primary System to the Standby System Set Up the Environment to Support the Standby Database Start the Physical Standby Database Verify the Physical Standby Database Is Performing Properly 2. Later.4 Primary 2. Step 1 Copy the primary database parameter file to the standby database. create the control file for the standby database. Note: You cannot use a single control file for both the primary and standby data bases.2 Primary 2. a text initialization para meter file can be copied to the standby location and modified.1 Create a Backup Copy of the Primary Database Datafiles ----------------------------------------------------------You can use any backup copy of the primary database to create the physical stand by database.3 Primary 2. SQL> ALTER DATABASE OPEN.2 Create a Control File for the Standby Database --------------------------------------------------If the backup procedure required you to shut down the primary database.5. Step 2 . issue th e following SQL*Plus statement to start the primary database: SQL> STARTUP MOUNT. you will convert this file back to a server paramete r file after it is modified to contain the parameter values appropriate for use with the physi cal standby database. 2. 2.2. and open the primary dat abase to user access.6 Standby 2. as long as you have the necessary archived redo log files to comple tely recover the database.3 Prepare an Initialization Parameter File for the Standby Database ---------------------------------------------------------------------Perform the following steps to create a standby initialization parameter file.

ALL_ROLES) DB_UNIQUE_NAME=boston' ** **LOG_ARCHIVE_DEST_2= 'SERVICE=chicago LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES. Although most of the initialization parameter settings in the text initializ ation parameter file that you copied from the primary system are also appr opriate for thephysical standby database.'/arch1/boston/'. . DB_NAME=chicago **DB_UNIQUE_NAME=boston** LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago.boston)' **CONTROL_FILES='/arch1/boston/control1. Parameter values that are different from Example 3 3 and Example 3 4 are shown in b/w *'s The parameters shown in Example 3 5 are valid for the Boston database when it is r unning in either the primary or the standby database role. Example 3 5 Modifying Initialization Parameters for a Physical Standby Database .'boston' ** **LOG_FILE_NAME_CONVERT='/arch1/chicago/'.ctl' ** **DB_FILE_NAME_CONVERT='chicago'. '/arch2/boston/control2.PRIMARY_ROLE) DB_UNIQUE_NAME=chicago' ** LOG_ARCHIVE_DEST_STATE_1=ENABLE LOG_ARCHIVE_DEST_STATE_2=ENABLE REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE STANDBY_FILE_MANAGEMENT=AUTO ** FAL_SERVER=chicago ** ** FAL_CLIENT=boston ** .'/a rch2/boston/' ** LOG_ARCHIVE_FORMAT=log%t_%s_%r. . some modifications need to be m ade.Set initialization parameters on the physical standby database. .ctl'.arc **LOG_ARCHIVE_DEST_1= 'LOCATION=/arch1/boston/ VALID_FOR=(ALL_LOGFILES.'/arch2/chicago/'. Example 3 5 shows the portion of the standby initialization parameter file where v alues were modified for the physical standby database.

This par ameter converts the path names of the primary database datafiles to the standby datafile path names. In Example 3. When the Bos running in the standby role. FAL_SERVER is the database ton database is hicago database redo end the missing FAL_CLIENT Oracle Net service name of the FAL server (typically this running in the primary role). The following table provides a brief explanation about the parameter settings sh own in Example 3 5 that have different settings from the primary database. If the standby database is on the same system as the primary database or if the directorstructur e where the log files are located on the standby sys tem is different from the primary system. ¡ LOG_ARCHIVE_DEST_2 is currently ignored because this destin ation is valid only for the primary role. then it will transmit redo data to the remote Chicago destination. If a switchover occurs and this instance becomes the primary database. If the standby database is o n the same system as the primary database or if the d irectory structure where the datafiles are located on the standby site is different from the primary site. CONTROL_FILES the path name for the control files on the standby databas e..5: ¡ LOG_ARCHIVE_DEST_1 archives redo data received from the pri mary database to archived redo log fi les in /arch1/boston/. ensure the COMPATIBLE initialization parameter is set to the same v alue on both the primary and standby databases. it uses the C as the FAL server from which to fetch (request) missing archived log files if Chicago is unable to automatically s log files. then this parameter is required. Oracle Net service name of the Boston database. Parameter Recommended Setting DB_UNIQUE_NAME a unique name for this database. Note that the example assumes the use of the LGWR process to transmit redo data to both the local and remote destinations on the LOG_ARCHIVE_DEST_2 initializati on parameter. This name stays with the database and does not change even if the primary and st andby databases reverse roles. . The FAL se LOG_ARCHIVE_DEST_n . This parameter c onverts the path names of the primary database log files to the path names on the standby database. LOG_FILE_NAME_CONVERT the location of the primary database online redo log files followed by the standby location. DB_FILE_NAME_CONVERT the path name and filename location of the primary databas e datafiles followed by the standby location. Specify where the redo data is to be archived. In addition. then this parameter is required.

and service that you specified when you configured .2 ¡ Initialization parameter file created in Section 3.5 Set Up the Environment to Support the Standby Database ----------------------------------------------------------Perform the following steps to create a Windows-based service. create a password file. use Oracle Net Manager to create a network service name for the primary and standby databases that will be used by redo transport services. and create a SPFILE. On both the primary and standby sites. Step 2 Create a password file. enter the following L SNRCTL utility commands on both the primary and standby systems: % lsnrctl stop % lsnrctl start Step 4 Create Oracle Net service names. On both the primary and standby systems. archived redo log files to 2. The Oracle Net service name must resolve to a connect descriptor that uses the s ame protocol. port. create a password file.2. For example: WINNT> oradim -NEW -SID boston -INTPWD password -STARTMODE manual See Oracle Database Platform Guide for Microsoft Windows (32-Bit) for more infor mation about using the ORADIM utility. and set the password fo r the SYS user to the same password used by the SYS user on the primary database. use the ORADIM utili ty to create a Windows Service and password file. To restart the listeners (to pick up the new definitions).rver (Chicago) copies missing the Boston standby database. Step 3 Configure listeners for the primary and standby databases.4 Copy Files from the Primary System to the Standby System ------------------------------------------------------------Use an operating system copy utility to copy the following binary files from the primary system to the standby system: ¡ Backup datafiles created in Section 3. set up the Oracle Net environment.2. use Oracle Net Manager to configure a lis tener for the respective databases. Step 1 Create a Windows-based service.1 ¡ Standby control file created in Section 3.2. The password for the SYS user on every database in a Data Guard configuration must b e identical for redo transmission to succeed. host address. On platforms other than Windows.3 2. If the standby system is running on a Windows-based system.

force a log switch and archive a few online redo log files on the primary database. and then check the standby database again. To see that redo data is being received on the standby database. the transmission of redo data to the remote standby location do es not occur until after a log switch. 2.7 Verify the Physical Standby Database Is Performing Properly ---------------------------------------------------------------Once you create the physical standby database and set up redo transport services . use the SQL CREATE statement to create a server parameter file for the standby database from the text initialization parameter f ile that was prepared for the stdby db For example: SQL> CREATE SPFILE FROM PFILE='initboston. query the V$ARCHIVED_LOG view to identify existing file s in the archived redo log. The following steps show how to perform these tasks. 2. Step 2 Start Redo Apply.the listeners for the primary and standby databases. Step 3 Test archival operations to the physical standby database. Step 5 Create a server parameter file for the standby database. To force a log switch so that redo data is tr ansmitted immediately. On the standby database. Step 1 Identify the existing archived redo log files. A log switch occurs. you may want to verify database modifications are being successfully transmitt ed from the primary database to the standby database. On the standby database. issue the following command to start Redo Apply: SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION. The statement includes the DISCONNECT FROM SESSION option so that Redo Apply run s in a background session. For example: SQL> ALTER SYSTEM SWITCH LOGFILE. On the standby database. The connect descriptor must als o specify that a dedicated server be used. issue the following SQL statement to start and mount th e database: SQL> STARTUP MOUNT. . Step 1 Start the physical standby database.ora'. you should firs t identify the existing archived redo log files on the standby database. On an idle standby database. use the following ALTER SYSTEM statement on the primary d atabase. when an online redo log file becomes full.6 Start the Physical Standby Database ---------------------------------------Perform the following steps to start the physical standby database and Redo Appl y. by default. In this example.

--8 YES 9 YES 10 YES 11 YES 4 rows selected. Step 4 Verify new archived redo log files were applied. On the standby database. The archived redo log files are now available to be applied to the physical stan dby database. SEQUENCE# FIRST_TIME NEXT_TIME ---------. NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#. Step 2 Force a log switch to archive the current online redo log file. Step 3 Verify the new redo data was archived on the standby database. FIRST_TIME. the physical standby database is running and can provide the maxi mum performance level of data protection. NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#.-----------------.-----------------8 11-JUL-02 17:50:45 11-JUL-02 17:50:53 9 11-JUL-02 17:50:53 11-JUL-02 17:50:58 10 11-JUL-02 17:50:58 11-JUL-02 17:51:03 3 rows selected. query the V$ARCHIVED_LOG view to verify the redo data w as received and archived on the standby database: SQL> SELECT SEQUENCE#. SQL> SELECT SEQUENCE#. FIRST_TIME.APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#. On the primary database. issue the ALTER SYSTEM SWITCH LOGFILE statement to forc e a log switch and archive the current online redo log file group: SQL> ALTER SYSTEM SWITCH LOGFILE. SEQUENCE# APP --------. query the V$ARCHIVED_LOG view to verify the archived re do log files were applied.-----------------. On the standby database. Post-Creation Steps ======================== At this point. The following list describes additiona . ________________________________________________________________________________ _______________________________ ======================== #3.-----------------8 11-JUL-02 17:50:45 11-JUL-02 17:50:53 9 11-JUL-02 17:50:53 11-JUL-02 17:50:58 10 11-JUL-02 17:50:58 11-JUL-02 17:51:03 11 11-JUL-02 17:51:03 11-JUL-02 18:34:11 4 rows selected.For example: SQL> SELECT SEQUENCE#. SEQUENCE# FIRST_TIME NEXT_TIME ---------.

l preparations you can take on the physical standby database: *Upgrade the data protection mode The Data Guard configuration is initially set up in the maximum performance mode (the default). *Enable Flashback Database Flashback Database removes the need to re-create the primary database after a fa ilover. the standby database. or both. You can enable Flashback Database on the primary database. .

Sign up to vote on this title
UsefulNot useful