Oracle DataGuard Documentation PDF
Oracle DataGuard Documentation PDF
Copyright
© 2007 MICROS Systems, Inc. All rights reserved. No part of this publication may be reproduced, photocopied,
stored on a retrieval system, or transmitted without the express prior written consent of the publisher. MICROS
Systems, Inc. retains the right to update or change the contents of this document without prior notice. MICROS
Systems, Inc. assumes no responsibility for the contents of this document.
OPERA is a trademark of MICROS Systems, Inc.
On Oracle and the On Oracle logo are trademarks of Oracle Corporation.
Information in this document is subject to change without notice.
MICROS Systems, Inc. makes no warranty of any kind with regard to this material, including but not limited to the
implied warranties of marketability and fitness for a particular purpose.
MICROS Systems, Inc. shall not be liable for errors contained herein or for incidental or consequential damages in
connection with the furnishing, performance, or use of this material.
Document Number:
Farid Zainol
Regional Database Administrator
Micros-Fidelio Asia Pacific
371 Beach Road
#11-00 KeyPoint
Singapore 199597
Voice: (+65) 6354 3990 / Fax: (+65) 6396 5419
Table of Contents
1.0 Introduction .............................................................................4
2.0 Configuration options for Dataguard............................................. 4
2.1 3- server setup ( 60 users +50 users) .......................................... 5
2.2 2- server setup (50 users) ..........................................................6
2.3 Recommended hardware ............................................................7
3.0 Installation of dataguard server ................................................... 7
3.1 Pre-Requisite checks ..................................................................7
3.2 Installation of Single Server ........................................................ 7
3.3 Changes on Primary Database server ........................................... 8
3.4 Changes on Dataguard server ................................................... 11
3.5 Copy Production database to Dataguard server ............................ 15
3.6 Activating the Production server ................................................ 15
3.7 Activating the Dataguard Server ................................................ 18
4.0 Verifying Dataguard ................................................................. 21
5.0 Dataguard Operations .............................................................. 22
5.1 STANDBY SWITCHOVER ........................................................... 23
5.2 STANDBY FailOVER .................................................................. 26
6.0 Rebuilding the standby server ................................................... 28
7.0 Scheduled Tasks ..................................................................... 33
6.1 START_STANDBY .................................................................... 33
6.2 daily_report............................................................................ 38
8.0 Application Changes ................................................................ 44
9.0 Appendix A ............................................................................. 45
1.0 INTRODUCTION
Oracle Data Guard is the most effective and comprehensive Disaster Recovery solution
available today for enterprise data
What is Dataguard?
There are 2 available options for the setup of Oracle Dataguard. Please note that these
configurations are base installations and additional applications can be added to these
configurations with no impact to Dataguard.
An important point to take note is that Opera Single Server should be used to install the
Dataguard server unless it is not planned for it to be used as an application server.
• Dataguard server must be installed with the same OS as the Production server.
• All servers must be installed with the same version of Oracle
In the diagram above, it shows the setup which consists of 3 physical servers.
There are 4 possible scenarios for this setup.
1) Normal Situation
The Database server updates the Dataguard Database
The Application server allows user connections
The Dataguard server allows user connections
In the diagram above, it shows the setup which consists of 3 physical servers.
There are 3 possible scenarios for this setup.
4) Normal Situation
The Database server updates the Dataguard server.
The Dataguard server allows user connections
Installation Media
Be sure to use the same version of media kits throughout the installation.
32bit/64bit Windows
Make sure the servers are on the same version of windows. The installation of Dataguard
on cross-server architecture is not supported.
Install the Opera 403 Single Server on the D:\ drive of both servers as per the Single
Server Installation document.
db_unique_name=production
log_archive_dest_1 = "location=d:\oracle\admin\opera\archive mandatory
REOPEN=120"
log_archive_dest_2='SERVICE=standby ARCH'
log_archive_dest_state_1=ENABLE
log_archive_dest_state_2=enable
log_archive_format = %%ORACLE_SID%%T_%TS%S%R.ARC
remote_login_passwordfile=exclusive
fal_server=standby
fal_client=production
standby_archive_dest='D:\oracle\admin\opera\archive\standby'
standby_file_management=auto
log_file_name_convert=('d:\oracle\oradata\opera\','d:\oracle\oradata\opera\')
db_file_name_convert=('d:\oracle\oradata\opera\','d:\oracle\oradata\opera\')
Next Log into the Production database and create an SPFILE from the Init file by issuing
“CREATE SPFILE FROM INITFILE=
’D:\ORACLE\ADMIN\OPERA\PFILE\INITOPERA.ORA’;”
Create directories
“D:\ORACLE\admin\opera\archive\standby”
db_unique_name=standby
fal_server=production
fal_client=standby
log_file_name_convert=('d:\oracle\oradata\opera\','d:\oracle\oradata\opera\')
db_file_name_convert=('d:\oracle\oradata\opera\','d:\oracle\oradata\opera\')
standby_archive_dest='D:\ORACLE\admin\opera\archive\standby'
standby_file_management=AUTO
log_archive_dest_2='SERVICE=production'
log_archive_dest_state_2=defer
log_archive_dest_1 = "location=D:\oracle\admin\opera\archive mandatory
reopen=120"
log_archive_dest_state_1=ENABLE
log_archive_format = %%ORACLE_SID%%T_%TS%S%R.ARC
remote_login_passwordfile=exclusive
Next Log into the Dataguard database and create an SPFILE from the Init file by issuing
“CREATE SPFILE FROM INITFILE=
’D:\ORACLE\ADMIN\OPERA\PFILE\INITOPERA.ORA’;”
Create directories
“D:\ORACLE\admin\opera\archive\standby”
Next would be to copy the production database to the Dataguard server. There are 2 ways
to do this.
RMAN Backup
This is explained in detail in Section 6 of this document.
**Please note these steps require the database to have a short downtime**
Start the Standby database by issuing “Alter database recover managed standby database
using current logfile disconnect from session;”
To check if Dataguard is working correctly, this must always be done after an install.
Log into the PRODUCTION server and issue “ALTER SYSTEM SWITCH LOGFILE”
Log into the Standby server and issue “SELECT SEQUENCE#,APPLIED FROM
V$ARCHIVED_LOG;”
If the logs are applied successfully, this means your Dataguard server is working
correctly.
Included with this documentation are some scripts which should be copied to the D:
This should include the folders
• Standby Switchover
• Standby Failover
The Difference between a Switchover and a Failover is that after a Failover, the Standby
Database becoming a Primary now, cannot switchback to become a Standby Database
again.
In Opposition a Switchover exchanges the Database Roles (The Primary becomes a
Standby and the Standby becomes a Primary). Switchovers can be performed arbitrarily,
a Failover only once.
We will go into detail on what these scripts do.
A switchover is a role reversal between the primary database and one of its standby
databases. Switchover operation guarantees no data loss. This is typically done for
planned maintenance of the primary system. During a switchover, the primary database
transitions to a standby role and the standby database transitions to the primary role. The
transition occurs without having to recreate either database.
This will contain the file Primary_to_standby.bat. Double click on this file to run.
Primary_to_standby.bat
sqlplus "sys/opera10g as sysdba" @Primary_to_standby.sql
Primary_to_standby.sql
spool primary_to_standby.log
alter database commit to switchover to standby with session shutdown;
shutdown immediate;
startup nomount;
alter database mount standby database;
recover managed standby database disconnect from session;
alter system set log_archive_dest_state_2=defer;
spool off
What this script does is that it will actually close the database and start it up as a standby
database.
This will contain the file Standby_to_primary.bat. Double click on this file to run.
Standby_to_primary.bat
sqlplus "sys/opera10g as sysdba" @standby_to_primary.sql
Standby_to_Primary.sql
spool standby_to_primary.log
alter database commit to switchover to primary with session shutdown;
shutdown immediate;
startup;
alter system set log_archive_dest_state_2=enable scope=both;
spool off
What this script does is that it will actually close the database and start it up as an open
database (Production).
To verify that the command completed successfully, you can either
• view the Primary_to_standby.log
OR
• Query the database with “SELECT CONTROLFILE_TYPE,OPEN_MODE
FROM V$DATABASE;” This command should state that your Controlfile_type
is “OPEN” and the database should be “READ WRITE”
Oracle DataGuard is a Disaster Recovery (DR) Solution for Oracle Databases. The basic
idea behind DataGuard is a Standby Database performing all changes from a Primary
Database on itself, too. So the Standby Database should be a constantly updated copy of a
Primary Database.
In case of a loss of the Primary Database, the Standby can take over the Primary Role and
act as a Primary Database. A Failover can be performed when all or most of the
information until the Unavailability of the Primary Database was propagated to the
Standby.
This should be run only from the standby server and only if the primary database is
unavailable or the primary database recovery takes a longer time.
CAUTION
DO NOT RUN THIS OPTION WITHOUT A ORACLE DBA GUIDANCE
This should be run only from the standby server and only if the primary database is unavailable or
the primary database recovery takes a longer time.
Once the old primary is available, move the database to primary and recreate the standby database.
This has to be done by an oracle DBA.
This will contain the file Failover.bat. Double click on this file to run.
Failover.bat
sqlplus "sys/opera10g as sysdba" @failover.sql
Failover.sql
spool failover.log
alter database recover managed standby database cancel;
alter database activate standby database;
shutdown immediate;
startup;
alter system set log_archive_dest_state_2=defer;
spool off
What this script does is to finish the recovery process of the Dataguard server and Open
the database for access (Production).
This is achieved by backing up the current primary and restoring it to the failed primary
as standby database. Once it is recovered as standby and log shipped started, you may
switch the roles using the switchover scripts
d. Backup the standby control file and switch the log file
(RMAN> backup current controlfile for standby;
RMAN> Sql “alter system archive log current”;)
Step 2. Copy the backup files to the failed primary under same folder
b. Delete all the datafiles,redo logs, standby redo logs, control files from
D:\oracle\opera\oradata folder
a. Connect to target DB and auxiliary database (failed primary) (Run this from
current primary)
Step 5. Once restore and recovery is over start the standby database on the failed
primary using the start_standby.bat under the scripts folder
a. From current primary run “ archive log list;” to find the next archive log
c. On Standby, Make sure the logfile is received and applied on the standby b
running “select sequence#,applied from v$archived_log order by sequence#;”
Step 7. Once log shipping and applying are functional, you may switch the roles
using the switchover procedure explained above. Please note users will be
disconnected during the switchover.
You will be required to set up 2 Scheduled tasks for the DATAGUARD server.
They are
• START_STANDBY
• DAILY_REPORT
Both these batch files are included in the Script folder which should be in D:\
6.1 START_STANDBY
This batch file will be run at each server start up to allow the standby database to start
correctly.
START_STANDBY.BAT
SET ORACLE_SID=OPERA
SQLPLUS "SYS/opera10g AS SYSDBA" @D:\SCRIPTS\START_STANDBY.SQL
SQLPLUS "SYS/opera10g@production AS SYSDBA"
@D:\SCRIPTS\refresh_archivedest.SQL
START_STANDBY.SQL
SHUTDOWN IMMEDIATE;
STARTUP NOMOUNT;
ALTER DATABASE MOUNT STANDBY DATABASE;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE using current logfile
DISCONNECT FROM SESSION;
EXIT
Open Scheduled Tasks which is in your Control Panel and double click on Add
Scheduled Task
Click on Next
Select Browse
Restart the standby server and make sure that Dataguard is up and running by issuing
“SELECT CONTROLFILE_TYPE,OPEN_MODE FROM V$DATABASE;”
This command should state that your Controlfile_type is “STANDBY” and the
database should be “MOUNTED”
6.2 DAILY_REPORT
This batch file will be used to generate and send out a report daily to the IT staff of the
property on the status of the dataguard server.
Open Scheduled Tasks which is in your Control Panel and double click on Add
Scheduled Task
Click on Next
Select Browse
After this has been set-up, run D:\scripts\DAILY_REPORT.bat and the mail should be
sent out to the mail addresses set up. This report can also be found in D:\scripts\report.txt
deleting OPERAT_001S004680609523929.ARC
deleting OPERAT_001S004690609523929.ARC
deleting OPERAT_001S004700609523929.ARC
4 rows selected.
(This deletes the archive logs which are no longer needed.)
Archive Gaps
-------------
Archive Gap as on 04/06/07 04:00 is 0
(This should be 0, If not, your databases are out of sync)
0
(This should be 0, If not there is a problem apply the logs to the standby server.)
Directory of D:\
FINDATA 356
FININDX 28
LOGDATA 12
LOGINDX 88
NAMEDATA 376
NAMEINDX 132
OPERA_DATA 147
OPERA_INDX 97
OXI_DATA 361
OXI_INDX 494
QUICKDATA 463
QUICKINDX 453
RATEDATA 414
RATEINDX 390
RESVDATA 380
RESVINDX 296
SYSAUX 6
SYSTEM 10
TOOLS 0
UNDOTBS1 582
20 rows selected.
(Free space on Production DB, Just for information Only)
1 2
(No. Of Opera users on Production database Just for information only)
This will effectively update all entries and config files to point to the standby server.
9.0 APPENDIX A
Additional steps required if target database is installed with Opera Single Server
As you can see below, the datafile attached to SYS_READ tablespace has a different
resetlogs_time compared to other datafiles, you may get errors while backing up the
database using RMAN.
Workaround in this case is make the tablespace read write (this will set the resetlogs_time
same as others) before backup and set it back to read only after standby sever is up.