Sie sind auf Seite 1von 8

PHSICAL STANDY CONFIGURATION

1.

Create and configure physical Standby Database 10g PART I

Configure the Primary Database


1. Enable Archivelog Mode
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
SQL> archive log list
2. Create a Password File
If a password file does not exist for the primary database, create one using the following
steps:
[oracle@vmlinux1 ~]$ cd $ORACLE_HOME/dbs
[oracle@vmlinux1 dbs]$ orapwd file=orapwprod password=MySysPassword
SQL> alter system set remote_login_passwordfile=exclusive scope=spfile;
System altered.
SQL> shutdown immediate
SQL> startup open
3. Enable Force Logging (optional)
To place the primary database in forced logging mode, connect as SYS and run the following:
SQL> alter database force logging;
To verify force logging is enabled for the database:
SQL> select force_logging from v$database;
FORCE_LOGGING
-------------YES
4. Create Standby Redo Logs (optional)
SQL> select group#, thread#, bytes, members from v$log;
GROUP# THREAD# BYTES MEMBERS
---------- ---------- ---------- ---------1 1 52428800 2
2 1 52428800 2
3 1 52428800 2
The number of standby redo logs required for the physical standby database in this example
is (3 + 1) * 1 = 4 at 50MB each.
From the primary database, connect as SYS and run the following to create four standby
redo log file groups:
SQL> alter database add standby logfile thread 1 group 4 size 50m;
SQL> alter database add standby logfile thread 1 group 5 size 50m;
SQL> alter database add standby logfile thread 1 group 6 size 50m;
SQL> alter database add standby logfile thread 1 group 7 size 50m;
To verify the new standby redo log files:
SQL> select group#, type, member from v$logfile order by group#, member;
5. Configure the Primary Database Initialization Parameters
The parameters listed below should be placed in the initialization file for the primary
database.
# ---[ Dump Destination Parameters ] --- #
audit_file_dest='/u01/app/oracle/admin/prod/adump'

PHSICAL STANDY CONFIGURATION


background_dump_dest='/u01/app/oracle/admin/prod/bdump'
core_dump_dest='/u01/app/oracle/admin/prod/cdump'
user_dump_dest='/u01/app/oracle/admin/prod/udump'
# ---[ Role-independent Parameters ] --- #
archive_lag_target=900
compatible='10.2.0.5.0'
control_files='/u02/oradata/PROD/controlfile/o1_mf_6hc6stn9_.ctl',
'/u03/flash_recovery_area/PROD/controlfile/o1_mf_6hc6styy_.ctl'
db_name='prod'
db_create_file_dest='/u02/oradata'
db_recovery_file_dest='/u03/flash_recovery_area'
dispatchers='(PROTOCOL=TCP) (SERVICE=prodXDB)'
instance_name='prod'
log_archive_config='dg_config=(prod,stby)'
log_archive_max_processes=4
remote_login_passwordfile='exclusive'
# ---[ Primary Role Parameters ] --- #
db_unique_name='prod'
log_archive_dest_1='location=use_db_recovery_file_ dest valid_for=(all_logfiles,all_roles)
db_unique_name=prod'
log_archive_dest_2='service=stby.info valid_for=(online_logfiles,primary_role)
db_unique_name=stby'
log_archive_dest_state_1='enable'
log_archive_dest_state_2='defer'
service_names='prod.info, prod'
# ---[ Standby Role Parameters ] --- #
db_file_name_convert='/STBY/','/PROD/'
log_file_name_convert='/STBY/','/PROD/'
fal_server='prod','stby'
fal_client='prod'
standby_file_management='auto'
Several of the initialization parameters listed above can not be dynamically modified and
therefore will require the primary database to be bounced:
SQL> shutdown immediate
SQL> startup
6. Create a Backup of the Primary Database
A physical standby database can be created using either a hot or cold backup of the primary
as long as all of the necessary archivelogs are available to bring the standby database to a
consistent state.
[oracle@vmlinux1 ~]$ mkdir -p /u04/oracle/dg_staging
[oracle@vmlinux2 ~]$ mkdir -p /u04/oracle/dg_staging
From the primary host, perform an RMAN backup of the primary database that places the
backupset into the staging directory:
[oracle@vmlinux1 ~]$ rman target sys/MySysPassword@prod
RMAN> backup device type disk format '/u04/oracle/dg_staging/%U' database plus
archivelog;
7. Create a Standby Controlfile
Using the same process as above, create a standby controlfile in the staging directory using
RMAN:

PHSICAL STANDY CONFIGURATION

[oracle@vmlinux1 ~]$ rman target sys/MySysPassword@prod


RMAN> backup device type disk format '/u04/oracle/dg_staging/%U' current controlfile for
standby;
8. Prepare an Initialization Parameter for the Standby Database
From the primary database, create a pfile in the staging directory:
SQL> create pfile='/u04/oracle/dg_staging/initstby.ora' from spfile;
File created.
Next, modify the necessary parameters in the new pfile to allow the database to operate in
the standby role.
# ---[ Memory Parameters ] --- #
stby.__db_cache_size=905969664
stby.__java_pool_size=16777216
stby.__large_pool_size=16777216
stby.__shared_pool_size=285212672
stby.__streams_pool_size=0
# ---[ Dump Destination Parameters ] --- #
audit_file_dest='/u01/app/oracle/admin/stby/adump'
background_dump_dest='/u01/app/oracle/admin/stby/bdump'
core_dump_dest='/u01/app/oracle/admin/stby/cdump'
user_dump_dest='/u01/app/oracle/admin/stby/udump'
# ---[ Role-independent Parameters ] --- #
archive_lag_target=900
compatible='10.2.0.5.0'
control_files='/u02/oradata/STBY/controlfile/o1_mf_6hc6stn9_.ctl',
'/u03/flash_recovery_area/STBY/controlfile/o1_mf_6hc6styy_.ctl'
db_name='prod'
db_create_file_dest='/u02/oradata'
db_recovery_file_dest='/u03/flash_recovery_area'
dispatchers='(PROTOCOL=TCP) (SERVICE=STBYXDB)'
instance_name='stby'
log_archive_config='dg_config=(prod,stby)'
log_archive_max_processes=4
remote_login_passwordfile='exclusive'
# ---[ Primary Role Parameters ] --- #
db_unique_name='stby'
log_archive_dest_1='location=use_db_recovery_file_ dest valid_for=(all_logfiles,all_roles)
db_unique_name=stby'
log_archive_dest_2='service=prod.info valid_for=(online_logfiles,primary_role)
db_unique_name=prod'
log_archive_dest_state_1='enable'
log_archive_dest_state_2='enable'
service_names='stby.info, stby'
# ---[ Standby Role Parameters ] --- #
db_file_name_convert='/PROD/','/STBY/'
log_file_name_convert='/PROD/','/STBY/'
fal_server='prod','stby'
fal_client='stby'

PHSICAL STANDY CONFIGURATION


standby_file_management='auto'
9. Transfer Files to the Standby Host
Using an OS remote copy utility, transfer the backup of the primary database, standby
controlfile, and standby initialization parameter file to the standby host (vmlinux2):
[oracle@vmlinux1 ~]$ scp /u04/oracle/dg_staging/* vmlinux2:/u04/oracle/dg_staging/
Configure Oracle Net Components
Oracle Net Listener
Although not mandatory, create a named static listener entry in the listener.ora file for each
database in the Data Guard configuration:
Primary Host
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = PROD.INFO)
(SID_NAME = prod)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
)
)
INBOUND_CONNECT_TIMEOUT_LISTENER = 0
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmlinux1.info)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
Standby Host
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = STBY.INFO)
(SID_NAME = stby)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
)
)
INBOUND_CONNECT_TIMEOUT_LISTENER = 0
LISTENER =

PHSICAL STANDY CONFIGURATION


(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmlinux2.info)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
Restart Oracle Net Listener Service
After making changes to the listener.ora, restart the Oracle Net listener service on the
primary and standby host:
[oracle@vmlinux1 ~]$ lsnrctl reload
[oracle@vmlinux2 ~]$ lsnrctl reload
Oracle Net Aliases
The primary and standby host should contain an Oracle Net alias in the tnsnames.ora file for
all primary and standby net service names:
PROD.INFO =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmlinux1.info)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod.info)
)
)
STBY.INFO =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmlinux2.info)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = stby.info)
)
)

PHSICAL STANDY CONFIGURATION

Configure the Standby Database


This section contains the steps used to create, mount, and start Redo Apply services for the
physical standby database.
1. Create the Standby Password File
Create the password file on the standby database using the following steps:
[oracle@vmlinux2 ~]$ cd $ORACLE_HOME/dbs
[oracle@vmlinux2 dbs]$ orapwd file=orapwstby password=MySysPassword
2. Create an spfile for the Standby Instance
[oracle@vmlinux2 ~]$ sqlplus / as sysdba
SQL> create spfile from pfile='/u04/oracle/dg_staging/initstby.ora';
File created.
SQL> !ls -l $ORACLE_HOME/dbs
total 12
-rw-r----- 1 oracle oinstall 1536 Dec 8 22:20 orapwstby
-rw-r----- 1 oracle oinstall 4608 Dec 8 22:20 spfilestby.ora
3. Create and Start the Standby Instance
Start by creating the "dump directories" on the standby host as referenced in the standby
initialization parameter file:
[oracle@vmlinux2 ~]$ mkdir -p /u01/app/oracle/admin/stby/adump
[oracle@vmlinux2 ~]$ mkdir -p /u01/app/oracle/admin/stby/bdump
[oracle@vmlinux2 ~]$ mkdir -p /u01/app/oracle/admin/stby/cdump
[oracle@vmlinux2 ~]$ mkdir -p /u01/app/oracle/admin/stby/dpdump
[oracle@vmlinux2 ~]$ mkdir -p /u01/app/oracle/admin/stby/pfile
[oracle@vmlinux2 ~]$ mkdir -p /u01/app/oracle/admin/stby/scripts
[oracle@vmlinux2 ~]$ mkdir -p /u01/app/oracle/admin/stby/udump
Next, create and verify all directories on the standby host that will be used for database files
and the Flash Recovery Area:
[oracle@vmlinux2 ~]$ mkdir -p /u02/oradata/STBY/controlfile
[oracle@vmlinux2 ~]$ mkdir -p /u02/oradata/STBY/datafile
[oracle@vmlinux2 ~]$ mkdir -p /u02/oradata/STBY/onlinelog
[oracle@vmlinux2 ~]$ mkdir -p /u03/flash_recovery_area/STBY/archivelog
[oracle@vmlinux2 ~]$ mkdir -p /u03/flash_recovery_area/STBY/autobackup
[oracle@vmlinux2 ~]$ mkdir -p /u03/flash_recovery_area/STBY/backupset
[oracle@vmlinux2 ~]$ mkdir -p /u03/flash_recovery_area/STBY/controlfile
[oracle@vmlinux2 ~]$ mkdir -p /u03/flash_recovery_area/STBY/onlinelog
After verifying the appropriate environment variables are set on the standby host
($ORACLE_SID, $ORACLE_HOME, $PATH, $LD_LIBRARY_PATH), start the physical standby
instance:
[oracle@vmlinux2 ~]$ echo $ORACLE_SID
stby
[oracle@vmlinux2 ~]$ sqlplus / as sysdba

PHSICAL STANDY CONFIGURATION


SQL> startup nomount
4. Create the Physical Standby Database
From the standby host where the standby instance was just started, duplicate the primary
database as a standby using RMAN:
[oracle@vmlinux2 ~]$ rman target sys/MySysPassword@prod auxiliary
sys/MySysPassword@stby
RMAN> duplicate target database for standby;
RMAN> exit
The RMAN duplicate process above will read the backupset that was transferred to the
staging directory, clone the standby controlfile, mount the database on the new standby
controlfile, and restore the physical database files.
5. Start Redo Apply on the Standby Database
Now that the standby is in place, start Redo Apply on the standby database by putting it in
managed recovery mode.
SQL> alter database recover managed standby database disconnect;
To use Real Time Apply, run the following alternate version of the alter database command
to place the standby database in managed recovery mode:
SQL> alter database recover managed standby database using current logfile disconnect;
NOTE:To use real time apply standby logfile is mandatory.
Start Remote Archiving
With the standby database now in managed recovery mode, the next and final phase is to
start shipping redo data to the standby from the primary.
SQL> alter system set log_archive_dest_state_2=enable scope=both;
System altered.
To force the current redo logs to be archived immediately, use the following statement on
the primary database:
SQL> alter system archive log current;
System altered.
At this point, the standby database will continue to apply changes from archive redo logs
being transferred from the primary.
Redo Transport
From the primary database, perform a log switch and then verify the transmissions of the
archive redo log file was successful:
SQL> alter system switch logfile;
SQL> select status, error from v$archive_dest where dest_id = 2;
STATUS ERROR
--------- --------------------------------------------------------VALID
If the transmission was successful, the status of the destination will be VALID as shown
above. If for any reason the transmission was unsuccessful, the status will be INVALID and
the full text of the error message will be populated in the ERROR column which can be used

PHSICAL STANDY CONFIGURATION


to investigate and correct the issue.
Redo Apply
First, identify the existing archived redo redo logs on the standby database:
[oracle@vmlinux2 ~]$ sqlplus sys/MySysPassword@stby as sysdba
SQL> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
SQL> select sequence#, first_time, next_time, archived, applied from v$archived_log order
by sequence#;
From the primary database, archive the current log using the following SQL statement:
SQL> alter system archive log current;
Go back to the standby database and re-query the V$ARCHIVED_LOG view to verify redo
data was shipped, received, archived, and applied:
SQL> select sequence#, first_time, next_time, archived, applied from v$archived_log order
by sequence#;

Das könnte Ihnen auch gefallen