oracle dataguard concepts and architecture brian hitchcock ocp 10g dba sun microsystems...

57
Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems [email protected] [email protected] www.brianhitchcock.net Brian Hitchcock October 23, 2007 Page 1

Upload: catherine-mills

Post on 12-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

Oracle DataGuardConcepts and Architecture

Brian HitchcockOCP 10g DBA

Sun [email protected]

[email protected]

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 1

Page 2: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 2

Oracle DataGuard

Maintains a standby database– Archived redo logs on primary– Sent to standby and applied

Simple idea Many configuration options

– No attempt to cover them all here– Discuss several specific sets of options

Can become very complicated

Page 3: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 3

Oracle DataGuard

Comes in Two Flavors– Physical Standby

When I was young this was all we had… Read-only when not applying redo logs

– Logical Standby Can be read-write while applying redo logs Can add db objects to standby

Indexes for reporting Many options

Page 4: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 4

Themes

What is a standby?– ‘standby’ implies specific capabilities

Ready for failover Complete copy of primary No need to verify standby before failover

When is a standby not a standby?– When it doesn’t provide what name implies

Page 5: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 5

What is a standby database?

Database that we can fail over to Kept closely synchronized with primary db

– Up to the minute– Once a day

Primarily dedicated to being ready for failover– May also be used for reporting

Guaranteed to be an exact copy– To the point of last synchronization– Can catch up as long as redo logs available

Page 6: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 6

What is a standby database?

No question about standby– Is it a complete copy?– Is it ready for failover

Standby for reporting– Is standby providing accurate data for reports?

No one can change standby– No changes to data/objects in standby

If changes made to standby– Should be very obvious

Page 7: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 7

Before DataGuard?

Scripts, cron jobs– Copy archived redo logs from primary to standby– Apply redo logs on standby periodically

When script(s) executes

Standby db can’t be used for anything else– Constantly recovering

Failover– Open standby db with resetlogs– Can’t be standby again without rebuild– Can’t fail back to primary without rebuild

Page 8: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 8

Standby

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

StandbyDatabase

ArchivedRedo Logs

Scripts, Cron Jobs

Standby mounted, recoveringCan only be opened resetlogsOnce opened, can’t switch back

Can’t change standby db objects

Page 9: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 9

Why DataGuard? Part of Oracle RDBMS

– No scripts or cronjobs to maintain– Supported by Oracle– Can switch between primary/standby repeatedly– Redo sent and applied continuously (options)

Standby db can be used for other things– Read-only when not applying redo logs– Read-write with limitations (Logical Standby)

Failover– Primary fails, standby becomes primary– Can’t switch back without rebuild

Page 10: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 10

DataGuard Classic*

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

StandbyDatabase

ArchivedRedo Logs

DataGuard

Standby mounted, recoveringorStandby read-only, no apply

Can switch back and forth-Primary becomes standby-Standby becomes primary

*Before choice of physical or logical standby

Page 11: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 11

Applying Redo Logs

Default– Archived redo log complete on primary– Sent and applied to standby

Standby Redo Logs (Optional)– Redo sent to standby as it is written on primary

Real-time apply– No waiting for primary archive redo log complete

No waiting for primary log switch– Not to be confused with init.ora parameter

VALID_FOR=(STANDBY_LOGFILES,…)

Page 12: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 12

Standby Redo Logs

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

StandbyDatabase

StandbyRedo Logs

DataGuard

Primary redo written continuously to standbyNo waiting for primary log switch

ArchivedRedo Logs

Page 13: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 13

Typical Configurations

Standby dedicated for failover– Primary db

configured for log switch every 15 minutes

– Standby db always applying redo logs Behind primary by 15 minutes at most

Less if primary writes redo logs more often Use standby redo logs

Very close to primary at all times

Page 14: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 14

Typical Configurations

Standby for failover and reporting– Primary db

configured for log switch every 15 minutes

– Standby db apply redo logs 8pm to 5am

Long enough to apply 24 hours of redo logs Stop applying redo logs 5am to 8pm Standby up to 15 hours behind primary Open for reporting 15 hours a day

Reports use ‘old’ data

Standby data doesn’t change from 5am to 8pm

Page 15: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 15

Protection Modes Maximum Performance (default)

– Primary sends transactions to standby– Doesn’t wait for them to commit

Maximum Protection– Primary stops if standby doesn’t commit– Requires standby redo logs

Maximum Availability– Max protection but primary doesn’t stop– Switch to max perf until standby catches up

Switch back to max availability

Page 16: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 16

DataGuard Physical Standby

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

Log TransportServices

PhysicalStandby

Database

ArchivedRedo Logs

Log ApplyServices

DataGuard

Standby mounted, recoveringOrStandby read-only, no applyCan switch back and forth

Can’t change standby db objects

Page 17: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 17

Physical Standby a Standby?

Failover– Ready to failover?

Block by block copy of primary If any changes made, can’t failover

Standby had to be opened resetlogs to change

Refresh– No questions– Complete rebuild from primary

Only need backup of primary, nothing else

Page 18: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 18

Physical Standby

Just a copy of production Only needed in production

– Don’t need to do any dev, testing

Don’t need backups– Recover from backups of primary database

What is added to your infrastructure?– One database– No backups

Page 19: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 19

Physical vs Logical Standby

Physical Standby– ‘classic’ standby– Can’t connect to db while applying redo logs– Can be read only when not applying redo logs

Logical Standby– Applies redo logs from primary all the time

As long as SQL apply process is running

– Open for users for read and write Various restrictions Many configuration options

Page 20: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 20

DataGuard Logical Standby

PrimaryDatabase

Online RedoLogs

Log TransportServices

LogicalStandby

Database

ArchivedRedo Logs

SQL ApplyServices

Online RedoLogs

ArchivedRedo Logs

Standby open while redo applied

Can change db objects (restrictions)

Two sets of archivedredo logs

ArchivedRedo Logs

DataGuard

Page 21: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 21

DataGuard Logical Standby

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

LogicalStandby

Database

ArchivedRedo Logs

LogMinerExtract SQLDataGuard

SQL applied to Logical StandbyJust like any other database user

Page 22: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 22

Logical Standby

Standby is open, read-write Anything copied from primary

– Maintained by DataGuard Depending on Guard status

– DataGuard doesn’t maintain things added to standby

Guard status restricts who can update– This can be bypassed

Alter session or database Needed to import db objects into standby

Page 23: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 23

Logical Standby Guard Status All

– SYS can modify anything in standby database Standby

– SYS can modify anything– Other users can modify objects not maintained

by DataGuard Subject to normal user privs

None– Standby not protected by DataGuard– Any user can alter db objects

Subject to normal user privs

Page 24: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 24

Skipping

Schemas, tables, transactions– May be skipped automatically– Can be skipped manually

Why anything skipped?– Performance– Unsupported db objects– More later

Page 25: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 25

Logical Standby a Standby?

Failover– Ready to failover?

Not sure if standby is a complete copy

Tables, schemas, transactions skipped? Standby can be changed

Failover not prevented

Changes can be made

No warning that changes made

– Who knows what you are failing over to?

Page 26: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 26

Logical Standby a Standby?

Refresh– Additional db objects in standby need backup

Refresh from primary wipes out these objects– Complete rebuild from primary

Insert additional db objects– If standby fails

Need to recover standby db from backups Extract additional db objects from standby Refresh logical standby Insert additional db objects

Page 27: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 27

Refresh Standby

Physical Standby– Just refresh– Standard process– No debate

Logical Standby– Refresh wipes out unique db objects– Must extract them first– Refresh from primary– Load unique db objects

Page 28: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 28

Standby Fails

Physical– No problem, just a copy of primary– Refresh from primary

Logical– What about unique db objects– Recover standby from standby backups– Extract unique db objects– Refresh standby– Insert unique db objects

Logical standby db must be backed up

Page 29: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 29

Recovering Logical Standby

You wanted Logical– To add things

Indexes for reporting

How to recover Logical?– Rebuild physical from primary– Convert to logical– How to recreate the additional db objects/data?

If indexes, recreate them If data extracted from copy of primary?

Page 30: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 30

How It Works

Basic DataGuard setup Where to send archived redo logs? Primary

– Log_archive_dest_1 Location for local archived redo logs Location=/arch01/NY Valid_for=(All_Logfiles, All_Roles)

– Log_archive_dest_2 Sends archived redo logs to service name Service name points to standby Service=LA Valid_for=(Online_logfiles, Primary_Role)

– Tnsnames.ora Contains entry for service name for standby

Log_archive_dest_nWhere n is 1 to 10Specific value doesn’t matter

Page 31: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 31

How it works

Standby– Log_archive_dest_1

Location for local archived redo logs Not used while db is physical standby Location=/arch01/LA Valid_for=(All_Logfiles,

All_Roles)

– Log_archive_dest_2 Location receives archived redo logs from primary Location=/arch02/LA Valid_for=(Standby_logfiles,

Standby_Role)

Log_archive_dest_nWhere n is 1 to 10Specific value doesn’t matter

Page 32: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 32

Symmetrical init.ora/spfile Use three log_archive_dest_n parameters

– Setup on primary and standby– Don’t need to change for failover– Don’t need to change for fail-back

Create tnsnames.ora entry– On primary

Pointing to standby– On standby

Pointing to primary

Less maintenance for frequent failover/back

Page 33: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 33

DataGuard init.ora/spfile

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

StandbyDatabase

ArchivedRedo Logs

Log_archive_dest_1LOCATION=/arch01/NYVALID_FOR=(ALL_LOGFILES,ALL_ROLES)

Log_archive_dest_2LOCATION=/arch02/NYVALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE)

Log_archive_dest_3SERVICE=LAVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

Log_archive_dest_1LOCATION=/arch01/LAVALID_FOR=(ALL_LOGFILES,ALL_ROLES)

Log_archive_dest_2LOCATION=/arch02/LAVALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE)

Log_archive_dest_3SERVICE=NYVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

Db_unique_name=NY_DB Db_unique_name=LA_DB

Tnsnames.oraLA=(DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=<hostnameLA>)(PORT=1521)) (CONNECT_DATA= (SID=LA_DB) ) )

Tnsnames.oraNY=(DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=<hostnameNY>)(PORT=1521)) (CONNECT_DATA= (SID=NY_DB) ) )

Active Inactive Active Inactive Active for Logical Standby

Page 34: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 34

DataGuard init.ora/spfile

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

StandbyDatabase

ArchivedRedo Logs

Log_archive_dest_1LOCATION=/arch01/NYVALID_FOR=(ALL_LOGFILES,ALL_ROLES)

Log_archive_dest_2LOCATION=/arch02/NYVALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE)

Log_archive_dest_3SERVICE=LAVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

Log_archive_dest_1LOCATION=/arch01/LAVALID_FOR=(ALL_LOGFILES,ALL_ROLES)

Log_archive_dest_2LOCATION=/arch02/LAVALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE)

Log_archive_dest_3SERVICE=NYVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

Db_unique_name=NY Db_unique_name=LA

Tnsnames.oraLA=(DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=<hostnameLA>)(PORT=1521)) (CONNECT_DATA= (SID=LA_DB) ) )

Tnsnames.oraNY=(DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=<hostnameNY>)(PORT=1521)) (CONNECT_DATA= (SID=NY_DB) ) )

Active Inactive Active InactiveActive for Logical Standby

Page 35: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 35

DataGuard Reporting

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

LogicalStandby

Database

ArchivedRedo Logs

LogMinerExtract SQLDataGuard

Database objectsCopied from primaryMaintained by DataGuard

Database objects added toLogical standby database-- indexes for reporting

Page 36: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 36

Rebuild Reporting Standby

If additional standby db objects have no data– Indexes for reporting

Refresh from primary wipes out indexes Refresh standby

– Execute script to recreate indexes

Page 37: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 37

Create DataGuard Standby

Physical Standby Logical Standby

– Create physical standby– Convert to logical standby

Page 38: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 38

Create Physical Standby

On Primary database– Enable Forced Logging– Create password file– Setup init.ora/spfile parameters– Verify archiving enabled– Backup db (hot or cold)– Create standby control file

Don’t use backup control file

Page 39: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 39

Create Physical Standby

On Standby database– Copy db backup files from primary– Copy standby control file from primary– Setup init.ora/spfile parameters

Db_name same as primary db_name

– Start physical standby db– Verify physical standby working

Page 40: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 40

Convert to Logical Standby

On Primary database– Build LogMiner dictionary

On Standby database– Stop redo apply– Convert database to logical standby

Change db_name

– Restart db– Open resetlogs– Verify logical standby working

Page 41: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 41

Cascaded Standbys

DataGuard supports cascading standbys Primary sends redo to

– Physical standby A– Logical standby B

Physical standby A sends redo to– Physical standby B– Physical standby C

Logical standby B sends redo to Don’t you have enough to worry about?

Page 42: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 42

Real World Example

What I’m supporting now– Logical standby– 2 added schemas for custom app– Primary db supports Oracle Applications 11i

Requirements– Provide copy of primary 11i db for reporting

Oracle Discoverer– Provide copy of 20-30 tables for custom app– Additional schemas store custom app data

Extracted from standby copies of primary tables

Page 43: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 43

DataGuard Logical Real World

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

LogicalStandby

Database

ArchivedRedo Logs

LogMinerExtract SQLDataGuard

Database objectsCopied from primaryMaintained by DataGuard

Database objects added toLogical standby database-- 2 schemas for custom app-- store data extracted from standby copies of primary tables

Procs extract dataProcessed Data

Stored

Page 44: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 44

Real World Refresh/Recovery

Refresh– Backup standby db objects not in primary– Refresh standby from primary– Recreate additional db objects in standby

If Logical standby fails– Db objects not in primary are lost– Need to recover standby db– Extract db objects– Refresh standby from primary– Recreate additional db objects in standby

Page 45: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 45

Logical Standby Issues

Unsupported– Data types

BFILE, user-defined types

– PL/SQL supplied packages That modify metadata, DBMA_JAVA etc.

– Other things, see manual

If unsupported, automatically skipped– No notification of skipped objects– Examine primary for unsupported things

Does this sound like a standby?

Page 46: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 46

Logical Standby Issues

Processing– Everything done on primary has to be extracted

from redo logs and applied to standby db– Apply process is just another db user session

Primary db– Objects may not be well designed

Tables with poor (or no) indexes

– Updates on primary can be very slow when applied as SQL to standby

Does this sound like a standby?

Page 47: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 47

Logical Standby Issues

If applying to standby too slow– May have to skip for performance– To keep standby in synch per business reqmts

Ready for reporting once per day

Primary SQL depends on files on primary– Create java class

Class files not on standby DataGuard doesn’t maintain filesystems

– No notification of such problems

Does this sound like a standby?

Page 48: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 48

Logical Standby Issues

Performance impact– At any time, slow SQL may take days to complete– If you need standby in synch once per day

Must skip table

– If you must have this table in standby Must do full refresh from primary

– If you can and do skip the table Can’t support requirement for reporting on standby

You never know when this will happen

Page 49: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 49

Logical Standby Issues Logical Standby is like an application

– Needs control, review, careful release process

If Logical Standby is an ‘application’– Need dev, alpha, beta, prod– Logical standby database for dev, alpha, beta– Backups for additional dbs– Add space to primary production database?

Need to add space to 4 primary, 4 logical dbs

What is added to your infrastructure?– 4 standby databases – Backups for 4 standby databases

Does this sound like a standby?

Page 50: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 50

Logical Standby Issues

How can standby get out of synch?– Someone bypassed guard and left it off– Someone left guard altered to NONE– SYS altered db objects in standby– Schema, table, transaction skipped

No record of transactions skipped

– No utilities Compare logical standby to primary Compare tables standby/primary

Does this sound like a standby?

Page 51: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 51

Logical Standby Issues Logical apply process examines standby

– When applying update from primary to standby– Compares

Previous values on primary Current values on standby

– If different, refuses to apply update from primary– Apply process fails– Can’t apply anything more

must cure issue or skip table/transaction

Differences can go undetected indefinitely– Until next time primary updates object

Does this sound like a standby?

Page 52: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 52

Logical Standby Issues

Need backups of logical standby database– If there are any unique database objects

If there aren’t, why use logical standby?

Refresh or rebuild– Have to recover db objects unique to standby

After refresh– Previously skipped tables

Do we skip them again? Do we wait for them to need to be skipped?

Does this sound like a standby?

Page 53: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 53

Real World Redesign

PrimaryDatabase

Online RedoLogs

ArchivedRedo Logs

ArchivedRedo Logs

DataGuard

-- 2 schemas for custom app-- store data extracted from tables in physical standby database

Procs extract dataProcessed Data

Stored

PhysicalStandby

Database

Separate database dedicated to custom application

Page 54: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 54

Real World Redesign Custom Application database

– Dedicated for app schemas– Db link into physical standby– Backup provides recovery of app schemas

Physical Standby database– Let DataGuard do what it does well– None of the Logical Standby issues– Can be used as read-only for reporting

When not applying redo logs

Support an extra database– Don’t have to support Logical Standby

Page 55: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 55

Recommendation

Logical for reporting– Copy of primary– Add indexes to speed reporting– Add tables for aggregates

Objects added to standby– Easily recreated from a SQL script– Contain data that can always be regenerated

from copy of primary

Page 56: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 56

Recommendation

Physical standby– Is solid, dependable– No issues

Logical standby– Is it really a standby?– Is it ready for failover?– Is it providing complete data for reports?– Lots of issues– Is it worth the effort/risk?

Page 57: Oracle DataGuard Concepts and Architecture Brian Hitchcock OCP 10g DBA Sun Microsystems brian.hitchcock@sun.com brhora@aol.com  Brian

www.brianhitchcock.net

Brian Hitchcock October 23, 2007 Page 57

DataGuard Support Issues

Covered in 2nd presentation “Oracle DataGuard Logical Standby Support

Issues”