D17316 gc20 l05_phys_sql
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

D17316 gc20 l05_phys_sql

on

  • 674 views

 

Statistics

Views

Total Views
674
Views on SlideShare
674
Embed Views
0

Actions

Likes
0
Downloads
58
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Steps to Create a Physical Standby Database Perform the following steps to create a physical standby database by using SQL commands : 1. Prepare the primary database. 2. Back up the primary database. 3. Copy files to the standby system. 4. Set parameters on the physical standby database. 5. Start the standby database. 6. Configure Oracle Net Services. 7. Set parameters on the primary database. 8. Start the transport of redo.
  • Preparing the Primary Database The FORCE LOGGING mode determines whether or not the Oracle database server logs all changes in the database, except for changes to temporary tablespaces and temporary segments. The FORCE_LOGGING column in V$DATABASE contains a value of YES if the database is in FORCE LOGGING mode. Every database in a Data Guard configuration must use a password file, and the password for the SYS user must be identical on every system for redo data transmission to succeed. For details about creating a password file, see Oracle Database Administrator’s Guide . On the primary database, you define initialization parameters that control redo transport services while the database is in the primary role. There are additional parameters that you need to add that control the receipt of the redo data and log apply services when the primary database is transitioned to the standby role. If archiving is not enabled, issue the ALTER DATABASE ARCHIVELOG command to put the primary database in ARCHIVELOG mode and enable automatic archiving. See Oracle Database Administrator’s Guide for additional information about archiving.
  • Setting Initialization Parameters on the Primary Database On the primary database, you define initialization parameters that control redo transport services while the database is in the primary role. These parameters are described in more detail on the following pages.
  • LOG_ARCHIVE_CONFIG Specify the DG_CONFIG attribute on the LOG_ARCHIVE_CONFIG parameter to list the DB_UNIQUE_NAME of the primary and standby databases in the Data Guard configuration. This setting enables the dynamic addition of a standby database to a Data Guard configuration that has a Real Application Clusters primary database running in either maximum protection or maximum availability mode. By default, the LOG_ARCHIVE_CONFIG parameter enables the database to send and receive redo. After a role transition, you may need to specify these settings again using the SEND , NOSEND , RECEIVE , or NORECEIVE keywords. Note: The database must be in MOUNT mode to change the SEND , NOSEND , RECEIVE , or NORECEIVE settings. Use the V$DATAGUARD_CONFIG view to see the unique database names defined with the DB_UNIQUE_NAME and LOG_ARCHIVE_CONFIG initialization parameters, providing a view of the Data Guard environment from any database in the configuration. The first row of the view lists the unique database name of the current database that was specified with the DB_UNIQUE_NAME initialization parameter. Additional rows reflect the unique database names of the other databases in the configuration that were specified with the DG_CONFIG keyword of the LOG_ARCHIVE_CONFIG initialization parameter.
  • LOG_ARCHIVE_CONFIG (continued) The following example illustrates the use of V$DATAGUARD_CONFIG : SQL> show parameter log_archive_config NAME TYPE VALUE ------------------- ------- --------------------------- log_archive_config string dg_config=(EDT3R7P1_SITE1,EDT3R7P1_SITE2) SQL> select * from v$dataguard_config; DB_UNIQUE_NAME ------------------------------ EDT3R7P1_ORCL EDT3R7P1_SITE1 EDT3R7P1_SITE2 Note: The LOG_ARCHIVE_CONFIG initialization parameter replaces the REMOTE_ARCHIVE_ENABLE initialization parameter, which will be deprecated in a future release. Do not specify both parameters in the same SPFILE or text initialization parameter file.
  • LOG_ARCHIVE_DEST_ n By using the various LOG_ARCHIVE_DEST_ n attributes, you define most of the settings for the Data Guard configuration. The redo transport service is directly controlled by these settings. There are 35 different attributes that can be set for each LOG_ARCHIVE_DEST_ n parameter. Most have defaults that are adequate for most configurations. See Oracle Data Guard Concepts and Administration for a complete list and description of each. You should specify at least two LOG_ARCHIVE_DEST_ n parameters (where n is an integer from 1 to 10): one parameter for the required local archiving destination and another parameter for a standby location. Query the V$ARCHIVE_DEST view to see current settings of the LOG_ARCHIVE_DEST_ n initialization parameter. All LOG_ARCHIVE_DEST_ n parameters must contain, at a minimum, either a LOCATION or SERVICE attribute. In addition, you must have a LOG_ARCHIVE_DEST_STATE_ n parameter for each defined destination.
  • Oracle Database 10 g : Data Guard Administration 5 - LOCATION and SERVICE Attributes Each LOG_ARCHIVE_DEST_ n destination must specify either the LOCATION attribute or the SERVICE attribute to identify either a local disk directory or a remote database destination where redo transport services can transmit redo data. LOCATION : Each destination that specifies the LOCATION attribute must identify a unique directory path name. This is the local destination for archived redo logs. SERVICE : Specifies a valid Oracle Net Services name. This service may be one of the following: A standby database (either physical or logical) An archive log repository, allowing for off-site archiving of redo logs. An archive log repository is created by using a standby control file, starting the instance, and mounting the database. This destination contains no data files. Note: The Data Guard broker does not support this type of service. A cross-instance archival database environment is possible on both the primary and standby databases. In a RAC environment, each instance directs its archived redo logs to a single instance of the cluster. The recovery instance typically has a tape drive available to support RMAN backup and restore operations. Note: The Data Guard broker does not support this type of service. Note: There are no defaults for these attributes.
  • Oracle Database 10 g : Data Guard Administration 5 - LOG_ARCHIVE_DEST_STATE_ n The LOG_ARCHIVE_DEST_STATE_ n initialization parameter (where n is an integer from 1 to 10) specifies the state of the corresponding destination that is indicated by the LOG_ARCHIVE_DEST_n initialization parameter (where n is the same integer). For example, the LOG_ARCHIVE_DEST_STATE_2 parameter specifies the state of the LOG_ARCHIVE_DEST_2 destination. The following are the valid values: ENABLE : specifies that a valid log archive destination can be used for a subsequent archiving operation (automatic or manual). This is the default. DEFER : specifies that valid destination information and attributes are preserved but that the destination is excluded from archiving operations until re-enabled. RESET : functions similarly to DEFER but clears any error messages for the destination if it had previously failed.
  • Oracle Database 10 g : Data Guard Administration 5 - Specifying Values for DB_FILE_NAME_CONVERT When the standby database is updated, the DB_FILE_NAME_CONVERT parameter is used to convert the data file name on the primary database to a data file name on the standby database. The file must exist and be writable on the physical standby database; if it is not, then the recovery process halts with an error. Specify the path name and file name location of the primary database data files followed by the standby location by setting the value of this parameter to two strings. The first string is the pattern found in the data file names on the primary database. The second string is the pattern found in the data file names on the physical standby database. You can use as many pairs of primary and standby replacement strings as required. You can use single or double quotation marks. The parentheses are optional. In the example in the slide, /oracle1/dba/ and /oracle2/dba/ are used to match for file names coming from the primary database. The strings /ora1/stby_dba/ and /ora2/stby_dba/ are the corresponding ones on the physical standby database. A file on the primary database named /oracle1/dba/system01.dbf is converted to /ora1/dba/system01.dbf on the standby database. Note: If the standby database uses Oracle Managed Files (OMF), do not set the DB_FILE_NAME_CONVERT parameter.
  • Oracle Database 10 g : Data Guard Administration 5 - Specifying Values for LOG_FILE_NAME_CONVERT The LOG_FILE_NAME_CONVERT parameter is used to convert the name of a redo log file on the primary database to the name of a redo log file on the standby database. Adding a redo log file to the primary database requires adding a corresponding file to the standby database. When the standby database is updated, this parameter is used to convert the log file name from the primary database to the log file name on the standby database. This parameter is required if the standby database is on the same system as the primary database or on a separate system that uses different path names. Specify the location of the primary database online redo log files followed by the standby location. The use of parentheses is optional. Note: If the standby database uses OMF, do not set the LOG_FILE_NAME_CONVERT parameter.
  • Oracle Database 10 g : Data Guard Administration 5 - Specifying a Value for LOG_ARCHIVE_FORMAT Use a text string and variables to specify the default file name format for archived redo log files. The string that is generated from this format is appended to the string that is specified in the LOG_ARCHIVE_DEST_ n and STANDBY_ARCHIVE_DEST parameters. The thread number refers to the redo thread. With a single instance, this is always 1; with RAC, this corresponds to the order in which the instances were started. Sequence number is the redo log sequence number. It starts at 0 or 1 and is incremented at each log switch. The database identifier (database ID) is calculated when the database is created and stored in all file headers. This value is not changed for the life of the database. The activation number is an internal number that is generated the first time the database is started. Subsequently, it is changed only when the database is opened with the RESETLOGS option. The resetlogs ID ensures unique names are constructed for the archived log files across multiple incarnations of the database. If the COMPATIBLE initialization parameter is set to 10.0 or higher, you must include %r in the LOG_ARCHIVE_FORMAT parameter. The length of the zero-filled versions of these directives is 8 on most platforms.
  • Oracle Database 10 g : Data Guard Administration 5 - Specifying a Value for STANDBY_FILE_MANAGEMENT When STANDBY_FILE_MANAGEMENT is set to AUTO , you cannot execute the following commands on the standby database: ALTER DATABASE RENAME ALTER DATABASE ADD/DROP LOGFILE [MEMBER] ALTER DATABASE ADD/DROP STANDBY LOGFILE MEMBER ALTER DATABASE CREATE DATAFILE AS ... When you add (or drop) a log file to the primary and want to add (or drop) it to the physical standby database as well, you must do the following: Set STANDBY_FILE_MANAGEMENT to MANUAL on the physical standby database. Add (or drop) the redo log files on the primary database. Add (or drop) them to the standby database. Reset to AUTO afterward on the standby database.
  • Oracle Database 10 g : Data Guard Administration 5 - ARCHIVE_LAG_TARGET The ARCHIVE_LAG_TARGET parameter defines the mean time to failover in the event your primary database fails and you must fail over to the standby. Although the redo is transmitted to the standby during normal operations, it is not applied to the standby database until the online redo log file on the primary has been completed. Note: If the real-time apply feature is enabled, log apply services can apply redo data as it is received, without waiting for the current standby redo log file to be archived. Real-time apply is described in detail in the lesson titled “Understanding the Oracle Data Guard Architecture.” For example, in a configuration where the online redo log file is 100 MB and 80 MB has been written, a failure at this point would mean that the 80 MB of redo must be applied to the standby before the failover can complete. If you need to limit the amount of time it takes to complete the failover, you can define this parameter to force a log switch after a certain amount of time, thereby enabling the redo to be applied. If you set this parameter to too small a value, the primary database log files switch too often and thus impact performance.
  • Oracle Database 10 g : Data Guard Administration 5 - LOG_ARCHIVE_TRACE Parameter You can set this parameter to trace the transmission of redo data to the standby system. To enable, disable, or modify the LOG_ARCHIVE_TRACE parameter in a primary database, do one of the following: Shut down the primary database, modify the initialization parameter file, and restart the database. Issue an ALTER SYSTEM SET LOG_ARCHIVE_TRACE=trace_level statement while the database is open or mounted. If you change the value of this parameter dynamically with an ALTER SYSTEM statement, the changes take effect at the start of the next archive operation. Refer to Oracle Data Guard Concepts and Administration for additional information.
  • LOG_ARCHIVE_TRACE Parameter (continued) The integer values for the LOG_ARCHIVE_TRACE parameter represent levels of tracing data. In general, the higher the level, the more detailed the information. You can combine tracing levels by setting the value of the LOG_ARCHIVE_TRACE parameter to the sum of the individual levels. For example, setting the parameter to 6 generates level 2 and level 4 trace output. The following integer levels are available:
  • Setting Initialization Parameters on the Primary Database In the example in the slide, assume that the primary database is named chicago and the standby is named boston . For each, there is an Oracle Net Services name defined. There are additional parameters you need to add that control the receipt of the redo data and log apply services when the primary database is transitioned to the standby role: FAL_SERVER=boston FAL_CLIENT=chicago DB_FILE_NAME_CONVERT='/arch1/boston/','/arch1/chicago/', '/arch2/boston/','/arch2/chicago/' LOG_FILE_NAME_CONVERT='/arch1/boston/','/arch1/chicago/', '/arch2/boston/','/arch2/chicago/' STANDBY_FILE_MANAGEMENT=AUTO Specifying these initialization parameters configures the primary database to resolve gaps, converts new data file and log file path names from a new primary database, and archives the incoming redo data when this database is in the standby role.
  • Backing Up the Primary Database by Using RMAN You can use any backup copy of the primary database to create the physical standby database, as long as you have the necessary archived redo log files to completely recover the database. It is recommended that you use Recovery Manager (RMAN). See Oracle High Availability Architecture and Best Practices for backup recommendations and Oracle Database Backup and Recovery Advanced User’s Guide for additional information about performing the RMAN backup operation.
  • Creating a Control File for the Standby Database On the primary database, you create the control file for the standby database. Create the control file by issuing the following command: ALTER DATABASE CREATE STANDBY CONTROLFILE AS file_name [REUSE]; If the file already exists, you can use the REUSE option to overwrite it. Note: You cannot use a single control file for both the primary and standby databases.
  • Copying Files to the Standby Database System After you have successfully backed up the data files and created the standby database control file, copy the files to the standby system by using an operating-system utility. If the physical standby database is on a different system from the primary database, then the directory paths may be the same. If the physical standby database is on the same system as the primary database, you must rename the primary data files in the standby control file after copying them to the standby location.
  • Oracle Managed Files (OMF) and Automatic Storage Management (ASM) If the primary database is configured to use OMF, Oracle recommends that the standby database be configured to use OMF as well. To do this, set the DB_CREATE_FILE_DEST and DB_CREATE_ONLINE_LOG_DEST_ n initialization parameters to appropriate values. Maintenance and future role transitions are simplified if the same disk group names are used for both the primary and standby databases. On the standby database, do the following: 1. If the standby database is going to use ASM, create an ASM instance if one does not already exist on the standby database system. 2. Use the RMAN BACKUP command to create a backup set that contains a copy of the primary database’s data files, archived log files, and a standby control file. 3. Use the RMAN DUPLICATE … FOR STANDBY command to copy the data files, archived redo log files, and standby control file in the backup set to the standby database’s storage area. The DUPLICATE … FOR STANDBY command performs the actual data movement at the standby instance. For more information about OMF and ASM, see the Oracle Database Administrator’s Guide. For more information about the DUPLICATE … FOR STANDBY command, see the Oracle Database Recovery Manager Reference .
  • Oracle Database 10 g : Data Guard Administration 5 - Setting Initialization Parameters on the Standby Database Create a text initialization parameter file (PFILE) from the server parameter file (SPFILE) that is used by the primary database. A PFILE can be copied to the standby location and modified. Issue the following command to create the PFILE: SQL> CREATE PFILE='/tmp/initboston.ora' FROM SPFILE; Later, you will convert this file back to a SPFILE after it is modified to contain the parameter values that are appropriate for use with the physical standby database. Although most of the initialization parameter settings in the text initialization parameter file that you copied from the primary system are also appropriate for the physical standby database, some modifications need to be made. The lines in italic in the slide indicate the parameters that need to be changed for use with the physical standby. The parameters shown are valid for the boston database when it is running in either the primary or the standby database role. In addition, ensure that the COMPATIBLE initialization parameter is set to the same value on both the primary and standby databases. If the values differ, redo transport services may be unable to transmit redo data from the primary database to the standby databases. In a Data Guard configuration, COMPATIBLE must be set to a minimum of 9.2.0.1.0. However, if you want to take advantage of new Oracle Database 10 g features, set the COMPATIBLE parameter to 10.1.0.0 or higher.
  • Oracle Database 10 g : Data Guard Administration 5 -
  • Oracle Database 10 g : Data Guard Administration 5 - Specifying a Value for STANDBY_ARCHIVE_DEST You can use the STANDBY_ARCHIVE_DEST initialization parameter on the standby database to indicate an alternative directory where the archived redo log files are to be stored when received from the primary database. The STANDBY_ARCHIVE_DEST initialization parameter overrides the directory location that is specified with the LOG_ARCHIVE_DEST_ n parameter if both the parameters are specified. You should set STANDBY_ARCHIVE_DEST to the same location as the local archive destination for the physical standby database so that all necessary archived redo log files for the standby database are in the same location. Because logical standbys have at least one local archive destination, STANDBY_ARCHIVE_DEST is not set in most configurations. STANDBY_ARCHIVE_DEST and LOG_ARCHIVE_FORMAT are used to construct a fully qualified file name.
  • Setting Up the Environment to Support the Standby Database 1. If the standby system is running on a Windows-based system, use the ORADIM tool to create a Windows service and password file. Here is an example: WINNT> oradim -NEW -SID boston -INTPWD password -STARTMODE manual Refer to Oracle Database Platform Guide for Windows for more information about using the ORADIM tool. 2. On platforms other than Windows, create a password file and set the password for the SYS user to the same password that is used by the SYS user on the primary database. The password for the SYS user on every database in a Data Guard configuration must be identical for redo transmission to succeed. Refer to the Oracle Database Administrator’s Guide for information about creating a password file. 3. On both the primary and standby sites, use Oracle Net Manager to configure a listener for the respective databases. To restart the listeners so that they recognize the new definitions, enter the following Listener Control utility commands on both the primary and standby systems: % lsnrctl stop % lsnrctl start Refer to the Oracle Net Services Administrator’s Guide for additional information about the Listener Control utility.
  • Setting Up the Environment to Support the Standby Database (continued) 4. On both the primary and standby systems, use Oracle Net Manager to create a network service name for the primary and standby databases that will be used by redo transport services. The Oracle Net Services name must resolve to a connect descriptor that uses the same protocol, host address, port, and SID that you specified when you configured the listeners for the primary and standby databases. The connect descriptor must also specify that a dedicated server be used. Refer to the Oracle Net Services Administrator’s Guide and the Oracle Database Administrator’s Guide . 5. On an idle standby database, use the CREATE SPFILE SQL statement to create a server parameter file for the standby database from the text initialization parameter file that was edited earlier, as shown in the following example: SQL> CREATE SPFILE FROM PFILE='initboston.ora';
  • Starting Up the Physical Standby Database 1. On the standby database, issue the STARTUP SQL statement to start the instance and open the database in read-only mode. 2. On the standby database, issue the ALTER DATABASE RECOVER MANAGED STANDBY DATABASE SQL command to start Redo Apply. This statement automatically mounts the database. Also, include the DISCONNECT FROM SESSION option so that Redo Apply runs in a background session. 3. The transmission of redo data to the remote standby location does not occur until after a log switch. Issue the following command on the primary to force a log switch: SQL> ALTER SYSTEM SWITCH LOGFILE;
  • Oracle Database 10 g : Data Guard Administration 5 - Additional Configuration Tasks Perform the following tasks if they are appropriate for your physical standby database: Configure standby redo logs: Standby redo logs are required for standby databases running in the maximum protection mode and maximum availability mode. However, configuring standby redo logs is recommended on all standby databases because, during a failover, Data Guard can recover and apply more redo data from standby redo log files than from the archived redo log files alone. The standby redo logs should exist on both primary and standby databases and have the same size and names. Enable real-time apply: When you enable the real-time apply feature, log apply services apply the redo data from standby redo log files in real time (at the same time the log files are being written to) as opposed to recovering redo from archived redo log files when a log switch occurs. Refer to the lesson titled “Understanding the Oracle Data Guard Architecture” for additional information about configuring real-time apply. Enable Flashback Database: Flashback Database removes the need to re-create the primary database after a failover. Flashback Database is similar to conventional point-in-time recovery in its effects, enabling you to return a database to a recent-past state. Flashback Database is faster than point-in-time recovery because it does not require restoring data files from backup or the extensive application of redo data. You can enable Flashback Database on the primary database, on the standby database, or on both.
  • Additional Configuration Tasks (continued) Upgrade the data protection mode: The Data Guard configuration is initially set up in the maximum performance mode (the default). Protection modes are discussed in detail in the lesson titled “Configuring Data Protection Modes and Redo Transport Services.”
  • Special Note: Standby Database on the Same System If you have a standby database on the same system as the primary database, you must consider the following: The data files must be renamed. The actual file names can be the same, but at least the directory path must be different. This means that you must use the DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT parameters. Note: If the standby database uses Oracle Managed Files (OMF), do not set the DB_FILE_NAME_CONVERT or LOG_FILE_NAME_CONVERT parameter. If a standby database is located on the same system as the primary database, the archival directories for the standby database must use a different directory structure than the primary database. Otherwise, the standby database may overwrite the primary database files. If you do not explicitly specify unique service names and if the primary and standby databases are located on the same system, the same default global name (consisting of the database name and domain name, from the DB_NAME and DB_DOMAIN parameters) will be in effect for both the databases. If the standby database is on the same system as the primary database, it does not protect against disaster. A disaster is defined as a total loss of the primary database system. If the standby database is on the same system, it will be lost as well. This configuration should be used for testing and training purposes only.
  • Oracle Database 10 g : Data Guard Administration 5 -

D17316 gc20 l05_phys_sql Presentation Transcript

  • 1. 5Creating a Physical Standby Database by Using SQL Copyright © 2006, Oracle. All rights reserved.
  • 2. ObjectivesAfter completing this lesson, you should be ableto use SQL commands to create a physical standbydatabase.5-2 Copyright © 2006, Oracle. All rights reserved.
  • 3. Steps to Create a Physical Standby Database 1. Prepare the primary database. 2. Back up the primary database. 3. Copy files to the standby system. 4. Set parameters on the physical standby database. 5. Start the standby database. 6. Configure Oracle Net Services. 7. Set parameters on the primary database. 8. Start the transport of redo.5-3 Copyright © 2006, Oracle. All rights reserved.
  • 4. Preparing the Primary Database • Enable FORCE LOGGING at the database level. SQL> ALTER DATABASE FORCE LOGGING; • Create a password file. • Set initialization parameters. • Enable archiving. SQL> SHUTDOWN IMMEDIATE; SQL> STARTUP MOUNT; SQL> ALTER DATABASE ARCHIVELOG; SQL> ALTER DATABASE OPEN;5-4 Copyright © 2006, Oracle. All rights reserved.
  • 5. Setting Initialization Parameters on the Primary Database Parameter Name Description LOG_ARCHIVE_CONFIG Specifies the unique database name for each database in the configuration LOG_ARCHIVE_DEST_n Controls redo transport services LOG_ARCHIVE_DEST_STATE_n Specifies destination state DB_FILE_NAME_CONVERT Converts primary database file names LOG_FILE_NAME_CONVERT Converts primary database log file names STANDBY_FILE_MANAGEMENT Controls automatic standby file management ARCHIVE_LAG_TARGET Forces a log switch after the specified number of seconds elapses LOG_ARCHIVE_TRACE Traces redo data transmission5-5 Copyright © 2006, Oracle. All rights reserved.
  • 6. LOG_ARCHIVE_CONFIG • Specify the DG_CONFIG attribute to list the DB_UNIQUE_NAME for the primary database and each standby database in the Data Guard configuration. • Additional LOG_ARCHIVE_CONFIG parameter values: – SEND: enables a database to send redo data to remote destinations. – RECEIVE: enables the standby database to receive redo from another database. – Use the NOSEND and NORECEIVE keywords to disable these settings. DB_NAME=chicago DB_UNIQUE_NAME=chicago LOG_ARCHIVE_CONFIG=DG_CONFIG=(chicago,boston)5-6 Copyright © 2006, Oracle. All rights reserved.
  • 7. 5-7 Copyright © 2006, Oracle. All rights reserved.
  • 8. LOG_ARCHIVE_DEST_n • Specify at least two LOG_ARCHIVE_DEST_n parameters. • Must contain (at a minimum) one of the following: – LOCATION – SERVICE • LOG_ARCHIVE_DEST_STATE_n parameter for each defined destination LOG_ARCHIVE_DEST_2= SERVICE=boston VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=boston LOG_ARCHIVE_DEST_STATE_2=ENABLE5-8 Copyright © 2006, Oracle. All rights reserved.
  • 9. LOCATION and SERVICE AttributesEach archive log destination includes one of the followingattributes: • LOCATION: specifies a valid path name. • SERVICE: specifies a valid Oracle Net Services name referencing a standby database. LOG_ARCHIVE_DEST_1= LOCATION=/arch1/chicago/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=chicago LOG_ARCHIVE_DEST_2= SERVICE=boston VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=boston5-9 Copyright © 2006, Oracle. All rights reserved.
  • 10. LOG_ARCHIVE_DEST_STATE_n • Defines the current state of an archive log destination: – ENABLE (default) – DEFER – RESET • Applies to the primary and standby database log_archive_dest_3=SERVICE=stby1_path1 ALTERNATE=LOG_ARCHIVE_DEST_4 log_archive_dest_4=SERVICE=stby1_path2 log_archive_dest_state_3=ENABLE5 - 10 Copyright © 2006, Oracle. All rights reserved.
  • 11. Specifying Values for DB_FILE_NAME_CONVERT • Must be defined on standby databases that have different disk or directory structures from the primary • Allows multiple pairs of file names • Applies to a database when in physical standby mode DB_FILE_NAME_CONVERT =(/oracle1/dba/, /ora1/stby_dba/, /oracle2/dba/, /ora2/stby_dba/)5 - 11 Copyright © 2006, Oracle. All rights reserved.
  • 12. Specifying Values for LOG_FILE_NAME_CONVERT • Similar to DB_FILE_NAME_CONVERT • Must be defined on standby databases that have different disk or directory structures from the primary • Online redo log files are used only when the standby becomes a primary. • Applies to a database when in physical standby mode LOG_FILE_NAME_CONVERT = (/oracle1/logs/, /ora1/stby_logs/)5 - 12 Copyright © 2006, Oracle. All rights reserved.
  • 13. Specifying a Value for LOG_ARCHIVE_FORMAT • Indicates the format for redo log file names • Format directives: – %t: Thread number – %T: Zero-filled thread number – %s: Sequence number – %S: Zero-filled sequence number – %d: Database ID – %D: Zero-filled database ID – %a: Current activation ID – %A: Zero-filled activation ID – %r: Resetlogs ID • Default value is operating-system dependent. LOG_ARCHIVE_FORMAT = %d_%t_%s_%r.arc5 - 13 Copyright © 2006, Oracle. All rights reserved.
  • 14. Specifying a Value for STANDBY_FILE_MANAGEMENT • Used to maintain consistency when you add or delete a data file on the primary database – MANUAL (default) — Data files must be manually added to the standby database. – AUTO — Adds the data file automatically to the standby database — Certain ALTER statements are no longer allowed on the standby database. • Applies to the primary database and physical standby database STANDBY_FILE_MANAGEMENT = auto5 - 14 Copyright © 2006, Oracle. All rights reserved.
  • 15. ARCHIVE_LAG_TARGET • Configure on primary database only • Set to the number of seconds after which a log switch must happen even if the log file is not full • Sets maximum time that a standby database must wait to process the redo • Default is 0 (disabled) • Range of values: 60 to 7,200 • Recommended value: 1,800 (30 minutes) ARCHIVE_LAG_TARGET = 18005 - 15 Copyright © 2006, Oracle. All rights reserved.
  • 16. LOG_ARCHIVE_TRACE Parameter • LOG_ARCHIVE_TRACE is optional and is used for diagnostic purposes. • Set this parameter to an integer value to see the progression of the archiving of redo logs to the standby system. – On the primary database, processes write an audit trail of the archived logs sent to the standby system into a trace file. – On the standby database, processes write an audit trail of the archived logs received from the primary database into a trace file. • Trace files are located in the directory specified by the USER_DUMP_DEST parameter.5 - 16 Copyright © 2006, Oracle. All rights reserved.
  • 17. 5 - 17 Copyright © 2006, Oracle. All rights reserved.
  • 18. Example: Setting Initialization Parameters on the Primary Database DB_NAME=chicago DB_UNIQUE_NAME=chicago SERVICE_NAMES=chicago LOG_ARCHIVE_CONFIG=DG_CONFIG=(chicago,boston) CONTROL_FILES=/arch1/chicago/control1.ctl, /arch2/chicago/control2.ctl LOG_ARCHIVE_DEST_1= LOCATION=/arch1/chicago/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=chicago LOG_ARCHIVE_DEST_2= SERVICE=boston 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.arc5 - 18 Copyright © 2006, Oracle. All rights reserved.
  • 19. Backing Up the Primary Database by Using RMAN • Create a backup copy of the primary database. • Use of RMAN is recommended. RMAN> BACKUP DATABASE5 - 19 Copyright © 2006, Oracle. All rights reserved.
  • 20. Creating a Control File for the Standby Database Create a control file on the primary database to be used for the standby database: SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE 2 AS /tmp/boston.ctl;5 - 20 Copyright © 2006, Oracle. All rights reserved.
  • 21. Copying Files to the Standby Database System Copy the following files to the standby database system: • Backup of the data files • Standby control file • Initialization parameter file Primary Standby5 - 21 Copyright © 2006, Oracle. All rights reserved.
  • 22. Oracle Managed Files (OMF) and Automatic Storage Management (ASM) • OMF: Use same on each database. • ASM: Use the RMAN DUPLICATE … FOR STANDBY command. OMF OMF primary standby5 - 22 Copyright © 2006, Oracle. All rights reserved.
  • 23. Setting Initialization Parameters on the Standby Database DB_NAME=chicago DB_UNIQUE_NAME=boston SERVICE_NAMES=boston LOG_ARCHIVE_CONFIG=DG_CONFIG=(chicago,boston) CONTROL_FILES=/arch1/boston/control1.ctl, /arch2/boston/control2.ctl DB_FILE_NAME_CONVERT= /arch1/chicago/,/arch1/boston/, /arch2/chicago/,/arch2/boston/ LOG_FILE_NAME_CONVERT=/arch1/chicago/,/arch1/boston/, /arch2/chicago/,/arch2/boston/ LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc Continued on the next page…5 - 23 Copyright © 2006, Oracle. All rights reserved.
  • 24. Setting Initialization Parameters on the Standby Database LOG_ARCHIVE_DEST_1= LOCATION=/arch1/boston/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=boston LOG_ARCHIVE_DEST_2= SERVICE=chicago VALID_FOR=(ONLINE_LOGFILES,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 INSTANCE_NAME=boston FAL_SERVER=chicago FAL_CLIENT=boston5 - 24 Copyright © 2006, Oracle. All rights reserved.
  • 25. Specifying a Value for STANDBY_ARCHIVE_DEST • Defines the standby database directory where the archived redo log files are created • Overrides the directory location that is specified with the LOG_ARCHIVE_DEST_n parameter STANDBY_ARCHIVE_DEST = /standby/arc_dest/ STANDBY_ARCHIVE_DEST = LOCATION=/standby/arc_dest/5 - 25 Copyright © 2006, Oracle. All rights reserved.
  • 26. Setting Up the Environment to Support the Standby Database 1. If creating a standby database on a Windows platform, create a Windows-based service. 2. Create a password file. 3. Configure listeners for the primary and standby databases.5 - 26 Copyright © 2006, Oracle. All rights reserved.
  • 27. Setting Up the Environment to Support the Standby Database 1. Create Oracle Net Services names. 2. Create a server parameter file for the standby database.5 - 27 Copyright © 2006, Oracle. All rights reserved.
  • 28. Starting the Physical Standby Database To start the physical standby database: • Bring it to the OPEN READ ONLY stage. • Start Redo Apply. • Test archival operations to the physical standby database: SQL> STARTUP; SQL> ALTER DATABASE RECOVER MANAGED STANDBY 2 DATABASE DISCONNECT FROM SESSION;5 - 28 Copyright © 2006, Oracle. All rights reserved.
  • 29. Additional Configuration Tasks Perform the following tasks as appropriate for your configuration: • Configure standby redo logs. • Enable real-time apply. • Enable Flashback Database. • Upgrade the data protection mode.5 - 29 Copyright © 2006, Oracle. All rights reserved.
  • 30. 5 - 30 Copyright © 2006, Oracle. All rights reserved.
  • 31. Special Note: Standby Database on the Same System Primary Standby /oracle/dba /oracle/standby/dba • Standby database data files must be at a different location. • Each database instance must archive to different locations. • Service names must be unique. • The standby database does not protect against disaster.5 - 31 Copyright © 2006, Oracle. All rights reserved.
  • 32. Summary In this lesson, you should have learned how to: • Create a physical standby with SQL commands • Enable FORCE LOGGING • Back up the primary database • Copy files to the standby system • Set parameters on the physical standby database • Start the standby database • Configure Oracle Net Services • Set parameters on the primary database • Start the transport of redo5 - 32 Copyright © 2006, Oracle. All rights reserved.