1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Cơ sở dữ liệu >

2 Creating a Physical Standby Database

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6 MB, 474 trang )


Creating a Physical Standby Database



Table 3–2 (Cont.) Creating a Physical Standby Database

Reference



Task



Database



Section 3.2.4



Copy Files from the Primary System to the Standby System



Primary



Section 3.2.5



Set Up the Environment to Support the Standby Database



Standby



Section 3.2.6



Start the Physical Standby Database



Standby



Section 3.2.7



Verify the Physical Standby Database Is Performing Properly



Standby



3.2.1 Create a Backup Copy of the Primary Database Datafiles

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. Oracle recommends that you use the Recovery Manager

utility (RMAN).

See Oracle High Availability Architecture and Best Practices for backup

recommendations and Oracle Database Backup and Recovery Advanced User's Guide to

perform an RMAN backup operation.



3.2.2 Create a Control File for the Standby Database

If the backup procedure required you to shut down the primary database, issue the

following SQL*Plus statement to start the primary database:

SQL> STARTUP MOUNT;



Then, create the control file for the standby database, and open the primary

database to user access, as shown in the following example:

SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/tmp/boston.ctl';

SQL> ALTER DATABASE OPEN;



Note: You cannot use a single control file for both the primary and



standby databases.



3.2.3 Prepare an Initialization Parameter File for the Standby Database

Perform the following steps to create a standby initialization parameter file.



Creating a Physical Standby Database 3-7



Creating a Physical Standby Database



Step 1 Copy the primary database parameter file to the standby database.

Create a text initialization parameter file (PFILE) from the server parameter file

(SPFILE) used by the primary database; a text initialization parameter file can be

copied to the standby location and modified. For example:

SQL> CREATE PFILE='/tmp/initboston.ora' FROM SPFILE;



Later, in Section 3.2.5, you will convert this file back to a server parameter file after

it is modified to contain the parameter values appropriate for use with the physical

standby database.

Step 2 Set initialization parameters on 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.

Example 3–3 shows the portion of the standby initialization parameter file where

values were modified for the physical standby database. Parameter values that are

different from Example 3–1 and Example 3–2 are shown in bold typeface. The

parameters shown in Example 3–3 are valid for the Boston database when it is

running in either the primary or the standby database role.

Example 3–3 Modifying Initialization Parameters for a Physical 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

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)



3-8



Oracle Data Guard Concepts and Administration



Creating a Physical Standby Database



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=boston

.

.

.



Note that the example assumes the use of the ARCn processes (the default) to

transmit redo data. If you specify the LGWR process to transmit redo data to both

the local and remote destinations, also include the NET_TIMEOUT attribute

(described in Chapter 12) on the LOG_ARCHIVE_DEST_2 initialization parameter.

In addition, ensure the COMPATIBLE initialization parameter is set to the same

value on both the primary and standby databases. If the values differ, log 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 10g features, set the COMPATIBLE parameter to 10.1.0.0 or higher.

It is always a good practice to use the SHOW PARAMETERS command to verify no

other parameters need to be changed.

The following table provides a brief explanation about the parameter settings

shown in Example 3–3 that have different settings from the primary database.

Parameter



Recommended Setting



DB_UNIQUE_NAME



Specify a unique name for this database. This name stays with the database and

does not change even if the primary and standby databases reverse roles.



SERVICE_NAMES



Specify a service name for this standby database that is unique from the primary

database service name. If you do not explicitly specify unique service names

and the primary and standby databases are located on the same system, the

same default global name (comprised of the database name, DB_NAME, and

domain name, DB_DOMAIN, parameters) will be in effect for both databases.



CONTROL_FILES



Specify the path name for the control files on the standby database. Example 3–3

shows how to do this for two control files. It is recommended that a second copy

of the control file is available so an instance can be easily restarted after copying

the good control file to the location of the bad control file.



Creating a Physical Standby Database 3-9



Creating a Physical Standby Database



Parameter



Recommended Setting



DB_FILE_NAME_CONVERT



Specify the path name and filename location of the primary database datafiles

followed by the standby location. This parameter converts the path names of the

primary database datafiles to the standby datafile path names. 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 standby site is different from the

primary site, then this parameter is required.



LOG_FILE_NAME_CONVERT



Specify the location of the primary database online redo log files followed by

the standby location. This parameter converts the path names of the primary

database log files to the path names on the standby database. If the standby

database is on the same system as the primary database or if the directory

structure where the log files are located on the standby system is different from

the primary system, then this parameter is required.



LOG_ARCHIVE_DEST_n



Specify where the redo data is to be archived. In Example 3–3:

s



s



LOG_ARCHIVE_DEST_1 archives redo data received from the primary

database to archived redo log files in /arch1/boston/.

LOG_ARCHIVE_DEST_2 is currently ignored because this destination is

valid only for the primary role. If a switchover occurs and this instance

becomes the primary database, then it will transmit redo data to the remote

Chicago destination.



Note: If a flash recovery area was configured (with the DB_RECOVERY_FILE_

DEST initialization parameter) and you have not explicitly configured a local

archiving destination with the LOCATION attribute, Data Guard automatically

uses the LOG_ARCHIVE_DEST_10 initialization parameter as the default

destination for local archiving. See Section 5.2.3 for more information. Also, see

Chapter 12 for complete information about LOG_ARCHIVE_DEST_n.

INSTANCE_NAME



Specify a different value for the standby database than the primary database

when the primary and standby databases reside on the same system.



FAL_SERVER



Specify the Oracle Net service name of the FAL server (typically this is the

database running in the primary role). When the Boston database is running in

the standby role, it uses the Chicago database as the FAL server from which to

fetch (request) missing archived redo log files if Chicago is unable to

automatically send the missing log files. See Section 5.8.



FAL_CLIENT



Specify the Oracle Net service name of the Boston database. The FAL server

(Chicago) copies missing archived redo log files to the Boston standby database.

See Section 5.8.



3-10



Oracle Data Guard Concepts and Administration



Creating a Physical Standby Database



Review the initialization parameter file for additional

parameters that may need to be modified. For example, you may

need to modify the dump destination parameters (BACKGROUND_

DUMP_DEST, CORE_DUMP_DEST, USER_DUMP_DEST) if the

directory location on the standby database is different from those

specified on the primary database. In addition, you may have to

create directories on the standby system if they do not already exist.



Caution:



3.2.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:

s



Backup datafiles created in Section 3.2.1



s



Standby control file created in Section 3.2.2



s



Initialization parameter file created in Section 3.2.3



3.2.5 Set Up the Environment to Support the Standby Database

Perform the following steps to create a Windows-based service, create a password

file, set up the Oracle Net environment, and create a SPFILE.

Step 1 Create a Windows-based service.

If the standby system is running on a Windows-based system, use the ORADIM

utility to create a Windows Service and password file. For example:

WINNT> oradim -NEW -SID boston -INTPWD password -STARTMODE manual



See Oracle Database Platform Guide for Windows for more information about using the

ORADIM utility.

Step 2 Create a password file.

On platforms other than Windows, create a password file, and set the password for

the SYS user to the same password 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. See Oracle Database

Administrator's Guide.



Creating a Physical Standby Database 3-11



Creating a Physical Standby Database



Step 3 Configure listeners for the primary and standby databases.

On both the primary and standby sites, use Oracle Net Manager to configure a

listener for the respective databases.

To restart the listeners (to pick up the new definitions), enter the following

LSNRCTL utility commands on both the primary and standby systems:

% lsnrctl stop

% lsnrctl start



See Oracle Net Services Administrator's Guide.

Step 4 Enable broken connection detection on the standby system.

Enable broken connection detection by setting the SQLNET.EXPIRE_TIME

parameter to 2 (minutes) in the SQLNET.ORA parameter file on the standby system.

For example:

SQLNET.EXPIRE_TIME=2



See Oracle Net Services Administrator's Guide.

Step 5 Create Oracle Net service names.

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

log transport services.

The Oracle Net service 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. See the Oracle Net Services

Administrator's Guide and the Oracle Database Administrator's Guide.

Step 6 Create a server parameter file for the standby database.

If you plan to immediately transition the physical standby database to a logical

standby database (as described in Chapter 4, "Creating a Logical Standby

Database"), then skip this step and proceed with the instructions in Section 3.2.6.

On an idle standby database, use the SQL CREATE statement to create a server

parameter file for the standby database from the text initialization parameter file

that was edited in Step 2 on page 3-8. For example:

SQL> CREATE SPFILE FROM PFILE='initboston.ora';



3-12



Oracle Data Guard Concepts and Administration



Creating a Physical Standby Database



3.2.6 Start the Physical Standby Database

Perform the following steps to start the physical standby database and Redo Apply.

Step 1 Start the physical standby database.

On the standby database, issue the following SQL statements to start and mount the

database in read-only mode:

SQL> STARTUP OPEN READ ONLY;



Do not open the database; it should remain closed to user access; a physical standby

database must be in the mounted state (or open in read-only mode) to receive redo

data.

Step 2 Create a new temporary file for the physical standby database.

If you plan to immediately transition the physical standby database to a logical

standby database (as described in Chapter 4, "Creating a Logical Standby

Database"), then skip this step and proceed with the instructions in Step 3.

Creating a new temporary file on the physical standby database now, rather than

later, is beneficial. Temporary files enable disk sorting when the database is open in

read-only mode and prepare the database for future role transitions.

To add temporary files to the physical standby database, perform the following

tasks:

1.



Identify the tablespaces that should contain temporary files. Do this by entering

the following command on the standby database:

SQL> SELECT TABLESPACE_NAME FROM DBA_TABLESPACES

2> WHERE CONTENTS = 'TEMPORARY';

TABLESPACE_NAME

-------------------------------TEMP1

TEMP2



2.



Add new temporary files to the standby database.

For each tablespace identified in the previous query, add a new temporary file

to the standby database. The following example adds a new temporary file

called TEMP1 with size and reuse characteristics that match the primary

database temporary files:

SQL> ALTER TABLESPACE TEMP1 ADD TEMPFILE



Creating a Physical Standby Database 3-13



Creating a Physical Standby Database



2> '/arch1/boston/temp01.dbf'

3> SIZE 40M REUSE;



Note: To create temporary files on the physical standby database



that match the temporary files on the primary database, query the

V$TEMPFILE view on the primary database to obtain complete

information about the primary database temporary files.

Step 3 Start Redo Apply.

On the standby database, issue the following command to start Redo Apply:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;



This statement automatically mounts the database. Also, the statement includes the

DISCONNECT FROM SESSION option so that Redo Apply runs in a background

session. See Section 6.3, "Applying Redo Data to Physical Standby Databases" for

more information.

Step 4 Test archival operations to the physical standby database.

The transmission of redo data to the remote standby location does not occur until

after a log switch. A log switch occurs, by default, when an online redo log file

becomes full. To force a log switch so that redo data is transmitted immediately, use

the following ALTER SYSTEM statement on the primary database. For example:

SQL> ALTER SYSTEM SWITCH LOGFILE;



3.2.7 Verify the Physical Standby Database Is Performing Properly

Once you create the physical standby database and set up log transport services,

you may want to verify database modifications are being successfully transmitted

from the primary database to the standby database.

To see that redo data is being received on the standby database, you should first

identify the existing archived redo log files on the standby database, force a log

switch and archive a few online redo log files on the primary database, and then

check the standby database again. The following steps show how to perform these

tasks.

Step 1 Identify the existing archived redo log files.

On the standby database, query the V$ARCHIVED_LOG view to identify existing

files in the archived redo log. For example:



3-14



Oracle Data Guard Concepts and Administration



Creating a Physical Standby Database



SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME

2 FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SEQUENCE#

---------8

9

10



FIRST_TIME

-----------------11-JUL-02 17:50:45

11-JUL-02 17:50:53

11-JUL-02 17:50:58



NEXT_TIME

-----------------11-JUL-02 17:50:53

11-JUL-02 17:50:58

11-JUL-02 17:51:03



3 rows selected.



Step 2 Force a log switch to archive the current online redo log file.

On the primary database, issue the ALTER SYSTEM ARCHIVE LOG CURRENT

statement to force a log switch and archive the current online redo log file group:

SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;



Step 3 Verify the new redo data was archived on the standby database.

On the standby database, query the V$ARCHIVED_LOG view to verify the redo data

was received and archived on the standby database:

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME

2> FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SEQUENCE#

---------8

9

10

11



FIRST_TIME

-----------------11-JUL-02 17:50:45

11-JUL-02 17:50:53

11-JUL-02 17:50:58

11-JUL-02 17:51:03



NEXT_TIME

-----------------11-JUL-02 17:50:53

11-JUL-02 17:50:58

11-JUL-02 17:51:03

11-JUL-02 18:34:11



4 rows selected.



The archived redo log files are now available to be applied to the physical standby

database.

Step 4 Verify new archived redo log files were applied.

On the standby database, query the V$ARCHIVED_LOG view to verify the archived

redo log files were applied.

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG

2 ORDER BY SEQUENCE#;

SEQUENCE# APP



Creating a Physical Standby Database 3-15



Further Preparations



--------8

9

10

11



--YES

YES

YES

YES



4 rows selected.

See Section 5.9.1, "Monitoring Log File Archival Information" and Section 6.3.4,

"Monitoring Log Apply Services on Physical Standby Databases" to verify log

transport services and log apply services are working correctly.



3.3 Further Preparations

At this point, the physical standby database is running and can provide the

maximum performance level of data protection. The following list describes

additional preparations you can take on the physical standby database:

s



Upgrade the data protection mode

The Data Guard configuration is initially set up in the maximum performance

mode (the default). See Section 5.6 for information about the data protection

modes and how to upgrade or downgrade the current protection mode.



s



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. See Section 5.6.2 for more information.



s



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 its state at a time in the recent

past. Flashback Database is faster than point-in-time recovery, because it does

not require restoring datafiles from backup or the extensive application of redo

data. You can enable Flashback Database on the primary database, the standby

database, or both. See Oracle Database Backup and Recovery Advanced User's Guide

for more information.



3-16



Oracle Data Guard Concepts and Administration



4

Creating a Logical Standby Database

This chapter steps you through the process of creating a logical standby database. It

includes the following main topics:

s



Preparing for Logical Standby Database Creation



s



Creating a Logical Standby Database



s



Further Preparations



The steps described in this chapter configure the standby database for maximum

performance mode, which is the default data protection mode. Chapter 5 provides

information about configuring the different data protection modes.

See also:

s



s



Oracle Database Administrator's Guide for information about creating and using

server parameter files

Oracle Data Guard Broker and the Oracle Enterprise Manager online help system

for information about using the graphical user interface to automatically create

a logical standby database



4.1 Preparing for Logical Standby Database Creation

Before you create a standby database, you must first ensure the primary database is

properly configured.

Table 4–1 provides a checklist of the tasks that you perform on the primary database

to prepare for logical standby database creation. There is also a reference to the

section that describes the task in more detail.



Creating a Logical Standby Database



4-1



Xem Thêm
Tải bản đầy đủ (.pdf) (474 trang)

×