DataGuard - Oracle's Time Machine

27
Data Guard The Actual Insurance of Data Navneet Upneja

Transcript of DataGuard - Oracle's Time Machine

Data Guard The Actual Insurance of Data

Navneet Upneja

Agenda

• Disaster Types

• Disaster Plan

• Data Guard Overview

• Standby Databases

• Data Guard Services

• Role Transitions

• Cascading Redo

• Far Sync

Disaster – Doesn’t need an Invitation

•No Disaster Recovery Plan?

So What do need?

Data Guard – Insurance of your Database Efficient business operations, high quality customer service and safeguarding

corporate information assets all require the highest possible level of data protection and data availability. Thus it is no surprise that data protection and data availability are among the top priorities for companies of all sizes and industries.

• Oracle Data Guard ensures high availability, data protection, and disaster recovery for enterprise data.

• Data Guard provides a comprehensive set of services that create, maintain, manage, and monitor one or more standby databases.

• Data Guard maintains these standby databases as transactionally consistent copies of the production database.

• if the production database becomes unavailable because of a planned or an unplanned outage, Data Guard can switch any standby database to the production role, minimizing the downtime associated with the outage

DATA GUARD - Overview • A Data Guard configuration consists of one production

database and one or more standby databases.

• The databases in a Data Guard configuration are connected by Oracle Net and may be dispersed geographically.

• There are no restrictions on where the databases are located, provided they can communicate with each other

• Operates on a simple principle: • Ship Redo

• Apply Reo

What is a Primary Database?

• A Data Guard configuration contains one production database, also referred to as the primary database, that functions in the primary role. This is the database that is accessed by most of your applications.

• The primary database can be either a single-instance Oracle database or an Oracle Real Application Clusters database.

What is a Standby database? • A standby database is a transactionally consistent copy of the primary

database.

• Using a backup copy of the primary database, you can create standby databases and incorporate them in a Data Guard configuration.

• Once created, Data Guard automatically maintains each standby database by transmitting redo data from the primary database and then applying the redo to the standby database.

• Physical Standby Database

• Logical Standby Database

• Snapshot Standby database

Physical Standby Database • A physical standby database is an exact, block-for-block copy of a

primary database. • A physical standby is maintained as an exact copy through a process

called Redo Apply, in which redo data received from a primary database is continuously applied to a physical standby database using the database recovery mechanisms.

• A physical standby database can be opened for read-only access and

used to offload queries from a primary database. • If a license for the Oracle Active Data Guard option has been

purchased, Redo Apply can be active while the physical standby database is open, thus allowing queries to return results that are identical to what would be returned from the primary database. This capability is known as the real-time query feature

Logical Standby Database • A logical standby database is initially created as an identical copy of the primary database,

but it later can be altered to have a different structure.

• The logical standby database is updated by executing SQL statements. This allows users to access the standby database for queries and reporting at any time.

• Data Guard automatically applies information from the archived redo log file or standby redo log file to the logical standby database by transforming the data in the log files into SQL statements and then executing the SQL statements on the logical standby database.

• Because the logical standby database is updated using SQL statements, it must remain open.

• While data that is being maintained by SQL Apply cannot be modified, additional objects can be created.

Snapshot Standby Database • A Snapshot standby database is a type of updatable standby database that

provides full data protection for a primary database.

• A Snapshot standby database receives redo and archives, but does not apply redo data from its primary database.

• Redo data received from the primary database is applied when a snapshot standby database is converted back into a physical standby database, after discarding all local updates to the snapshot standby database

Data Guard Services There are three types of Services: -

• Redo Transport Services : - Control the automated transfer of redo data from the production database to one or more archival destinations.

• LNSn

• ARCH

• Log Apply Services: - Apply redo data on the standby database to maintain transactional synchronization with the primary database.

• Redo Apply (Log Apply)

• SQL Apply

• Role Transitions: - Change the role of a database from a standby database to a primary database, or from a primary database to a standby database using either a switchover or a failover operation.

• Failover

• Switchover

Data Guard - ARCH

Data Guard – LGWR (LNS)

Creating Physical Standby Database

On Primary Database 1. Enable Force Logging “ALTER DATABASE FORCE LOGGING;”

2. LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORCL,ORCLDB)‘

3. LOG_ARCHIVE_DEST_2='SERVICE=ORCL NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCLDB';

4. FAL_SERVER=ORCLDB

5. TNS Entries

6. Backup Primary Database

7. Add Standby Redo Logs.

Cont.. On Standby Server

1. Copy Pfile from Primary and change the required parameters.

2. db_unique_name=‘ORCLDB‘

3. fal_server=‘ORCL’

4. log_archive_dest_2='SERVICE=ORCL ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCL‘

5. Create Standby Database using RMAN Duplicate Command.

Data Guard – Protection Modes

• Maximum Performance

Emphasis on Performance of Primary Database.

Redo Transport Mode is : ASYNC

LGWR in Primary NEVER waits for acknowledgement from Standby.

Default Mode of Redo Transfer in Oracle 11g using LGWR method of sending Redo data

If no standby database is available processing continues on primary.

log_archive_dest_2='service="orcldb", LGWR ASYNC NOAFFIRM delay=0 optional db_unique_name="orcldb" ';

Cont..

• Maximum Availability

Availability as First Priority.

ZERO data loss as close but still second priority.

Redo Transport Mode : SYNC

Primary Performance can get impacted depending upon the time taken to receive acknowledgement from Standby Server.

Primary Database wait for maximum of time defined using “NET_TIMEOUT” parameter of LOG_ARCHIVE_DEST_n parameter.

Defaults to 30secs

Cont..

• Maximum Protection

Utmost priority is DATA Protection

Redo Transport Mode : SYNC

Very much similar to Maximum Availability

Except, it does not consider NET_TIMEOUT Parameter

Continues to wait for Acknowledgement from Standby Server.

Till then, LGWR remain stalled.

Can impact Performance of Primary Database.

ROLE TRANSITIION

• SWITCHOVER

Planned Event

Reverses the role of Primary and Standby databases.

Minimizes downtime during planned Maintenance.

Process of Switchover Notifies Primary database about Switchover.

Disconnects users .

Generates special redo record “End of Redo” (EOR).

Convert Primary into Standby.

Apply EOR on standby and then converts standby into primary.

Cont..

On Primary Database

1. ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY;

2. STARTUP MOUNT;

3. ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;

On Standby Database 1. ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

2. SHUTDOWN IMMEDIATE;

3. Startup

Cont..

FAILOVER • Role Transition due to unplanned event.

• Similar to SWITCHOVER except Primary database did not get chance to generate EOR.

• Standby database apply last redo that is available on standby site.

• Anything after that is LOST.

• Data Lost depends upon the Protection mode in which Primary database was running.

• No Data Loss in case of Maximum Protection.

• Failover can be Manual or Automatic.

Cascade Redo Transport • Need to be using 11.2.0.2 or higher.

• Also known as Terminal Destination.

• Receives Redo from Standby Database rather than from Primary Database, Also known as “Indirect Redo”.

• Useful in cases where we have multiple standby databases

• In 12c, Cascading Redo can be done real Time.

• Only Physical standby databases can cascade redo.

Far Sync Standby Database • New in Oracle 12c database.

• Remote Data guard destination that receive redo from Primary Database.

• Ships redo to other conventional standby databases.

• Have Controlfile, Standby Redo Log Files

• Consume little disk and other system resources.

• Can be useful where actual Physical standby is places at far away location from Primary Database geographically.

Automatic Archive Gap Resolution