Oracle Dataguard Concepts and Architecture: Brian Hitchcock Ocp 10G Dba Sun Microsystems
Oracle Dataguard Concepts and Architecture: Brian Hitchcock Ocp 10G Dba Sun Microsystems
Page 1
Oracle DataGuard
Maintains a standby database
Simple idea
Many configuration options
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 2
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
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 3
Themes
What is a standby?
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 4
Up to the minute
Once a day
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 5
Is it a complete copy?
Is it ready for failover
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 6
Before DataGuard?
Scripts, cron jobs
Constantly recovering
Failover
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 7
Standby
Cant change standby db objects
Primary
Database
Standby
Database
Online Redo
Logs
Archived
Redo Logs
Archived
Redo Logs
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 8
Why DataGuard?
Part of Oracle RDBMS
Failover
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 9
DataGuard Classic*
*Before choice of physical or logical standby
Primary
Database
Standby
Database
Online Redo
Logs
Archived
Redo Logs
DataGuard
Archived
Redo Logs
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 10
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 11
Standby
Database
Online Redo
Logs
Archived
Redo Logs
Archived
Redo Logs
DataGuard
Standby
Redo Logs
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 12
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
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 13
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 doesnt change from 5am to 8pm
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 14
Protection Modes
Maximum Performance (default)
Maximum Protection
Maximum Availability
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 15
Online Redo
Logs
Log Transport
Services
Log Apply
Services
Physical
Standby
Database
Primary
Database
Archived
Redo Logs
DataGuard
Archived
Redo Logs
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 16
Ready to failover?
Block by block copy of primary
If any changes made, cant failover
Standby had to be opened resetlogs to change
Refresh
No questions
Complete rebuild from primary
Only need backup of primary, nothing else
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 17
Physical Standby
Just a copy of production
Only needed in production
One database
No backups
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 18
classic standby
Cant connect to db while applying redo logs
Can be read only when not applying redo logs
Logical Standby
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 19
SQL Apply
Services
Logical
Standby
Database
Primary
Database
Online Redo
Logs
Log Transport
Services
Online Redo
Logs
Archived
Redo Logs
DataGuard
Archived
Redo Logs
Archived
Redo Logs
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 20
Primary
Database
Online Redo
Logs
Archived
Redo Logs
DataGuard
Archived
Redo Logs
LogMiner
Extract SQL
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 21
Logical Standby
Standby is open, read-write
Anything copied from primary
Maintained by DataGuard
Depending on Guard status
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 22
Standby
None
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 23
Skipping
Schemas, tables, transactions
Performance
Unsupported db objects
More later
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 24
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
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 25
If standby fails
Need to recover standby db from backups
Extract additional db objects from standby
Refresh logical standby
Insert additional db objects
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 26
Refresh Standby
Physical Standby
Just refresh
Standard process
No debate
Logical Standby
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 27
Standby Fails
Physical
Logical
Page 28
To add things
Indexes for reporting
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 29
How It Works
Log_archive_dest_n
Where n is 1 to 10
Specific value doesnt matter
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
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 30
How it works
Standby
Log_archive_dest_n
Where n is 1 to 10
Specific value doesnt matter
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)
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 31
Symmetrical init.ora/spfile
Use three log_archive_dest_n parameters
On primary
Pointing to standby
On standby
Pointing to primary
Page 32
DataGuard init.ora/spfile
Active
Active
Inactive
Db_unique_name=NY_DB
Primary
Database
Online Redo
Logs
Archived
Redo Logs
Inactive
Db_unique_name=LA_DB
Log_archive_dest_1
LOCATION=/arch01/NY
VALID_FOR=(ALL_LOGFILES,
ALL_ROLES)
Log_archive_dest_1
LOCATION=/arch01/LA
VALID_FOR=(ALL_LOGFILES,
ALL_ROLES)
Log_archive_dest_2
LOCATION=/arch02/NY
VALID_FOR=(STANDBY_LOGFILES,
STANDBY_ROLE)
Log_archive_dest_2
LOCATION=/arch02/LA
VALID_FOR=(STANDBY_LOGFILES,
STANDBY_ROLE)
Log_archive_dest_3
SERVICE=LA
VALID_FOR=(ONLINE_LOGFILES,
PRIMARY_ROLE)
Log_archive_dest_3
SERVICE=NY
VALID_FOR=(ONLINE_LOGFILES,
PRIMARY_ROLE)
Tnsnames.ora
LA=(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)
(HOST=<hostnameLA>)(PORT=1521))
(CONNECT_DATA= (SID=LA_DB) ) )
Tnsnames.ora
NY=(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)
(HOST=<hostnameNY>)(PORT=1521))
(CONNECT_DATA= (SID=NY_DB) ) )
Standby
Database
Archived
Redo Logs
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 33
DataGuard init.ora/spfile
Active
Inactive
Db_unique_name=NY
Standby
Database
Archived
Redo Logs
Active
Inactive
Db_unique_name=LA
Log_archive_dest_1
LOCATION=/arch01/NY
VALID_FOR=(ALL_LOGFILES,
ALL_ROLES)
Log_archive_dest_1
LOCATION=/arch01/LA
VALID_FOR=(ALL_LOGFILES,
ALL_ROLES)
Log_archive_dest_2
LOCATION=/arch02/NY
VALID_FOR=(STANDBY_LOGFILES,
STANDBY_ROLE)
Log_archive_dest_2
LOCATION=/arch02/LA
VALID_FOR=(STANDBY_LOGFILES,
STANDBY_ROLE)
Log_archive_dest_3
SERVICE=LA
VALID_FOR=(ONLINE_LOGFILES,
PRIMARY_ROLE)
Log_archive_dest_3
SERVICE=NY
VALID_FOR=(ONLINE_LOGFILES,
PRIMARY_ROLE)
Tnsnames.ora
LA=(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)
(HOST=<hostnameLA>)(PORT=1521))
(CONNECT_DATA= (SID=LA_DB) ) )
Tnsnames.ora
NY=(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)
(HOST=<hostnameNY>)(PORT=1521))
(CONNECT_DATA= (SID=NY_DB) ) )
Primary
Database
Online Redo
Logs
Archived
Redo Logs
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 34
DataGuard Reporting
Logical
Standby
Database
Primary
Database
Online Redo
Logs
Archived
Redo Logs
Database objects
Copied from primary
Maintained by DataGuard
DataGuard
Archived
Redo Logs
LogMiner
Extract SQL
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 35
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 36
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 37
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 38
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 39
On Standby database
Restart db
Open resetlogs
Verify logical standby working
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 40
Cascaded Standbys
DataGuard supports cascading standbys
Primary sends redo to
Physical standby A
Logical standby B
Physical standby B
Physical standby C
Page 41
Logical standby
2 added schemas for custom app
Primary db supports Oracle Applications 11i
Requirements
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 42
Logical
Standby
Database
Database objects
Copied from primary
Maintained by DataGuard
Online Redo
Logs
Archived
Redo Logs
DataGuard
Archived
Redo Logs
Processed Data
Stored
LogMiner
Extract SQL
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 43
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 44
Unsupported
Data types
BFILE, user-defined types
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 45
Processing
Primary db
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 46
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 47
Page 48
4 standby databases
Backups for 4 standby databases
Does this sound like a standby?
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 49
No utilities
Compare logical standby to primary
Compare tables standby/primary
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 50
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 51
Refresh or rebuild
After refresh
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 52
Primary
Database
Physical
Standby
Database
Online Redo
Logs
Procs extract data
Archived
Redo Logs
DataGuard
Processed Data
Stored
Archived
Redo Logs
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 53
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 54
Recommendation
Logical for reporting
Copy of primary
Add indexes to speed reporting
Add tables for aggregates
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 55
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?
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 56
www.brianhitchcock.net
Brian Hitchcock October 23, 2007
Page 57