43
DBA’s Guide to Physical Dataguard Part II Ahbaid Gaffoor – Amazon.com/A9 ahbaid@{amazon.com|a9.com|att.net} NoCOUG.org : May 21 st 2009

DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

Embed Size (px)

Citation preview

Page 1: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard

Part IIAhbaid Gaffoor – Amazon.com/A9

ahbaid@{amazon.com|a9.com|att.net}NoCOUG.org : May 21st 2009

Page 2: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 2 / 43

OverviewSlides

• Recap from Part I• Standby Database• Physical Standby• Dataguard Configuration• Protection Levels

• Part II• Requirements• Protection Levels• VMware Setup &

Recommendations

Demo• Dataguard

• Config & Recap• Switchover

• Fast Start Failover• MAXIMUM AVAILABILITY• Flashback Database• Broker Configuration

• Anything else…

Page 3: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 3 / 43

Redo Archive Logs Transport Manual Recovery Manual Switch/Fail Over

DB

PRIMARY DB

Standby Database

DB

STANDBY DB

apply

Archive Logs

a1

a2

TRANSPORTscp, ftp, nfs

Archive Logs

arc0

a1

a2

a3

Redo logs

r1

lgwr r4

r3

r2

Page 4: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 4 / 43

Dataguard::OverviewPhysical Standby• Manual Transport• Manual Apply• Disconnected• Manual Switch/Fail over

Dataguard• Oracle Transport

• ARCH• LGWR

• Automatic Apply• Connected

• Broker• FSFO

• Faster Switch/Fail over• Protection Levels

• MAX PERFORMANCE• MAX AVAILABILITY• MAX PROTECTION

Page 5: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 5 / 43

VMware::OverviewVmware Server 2.0.0• DataStore – Directory• Create / Import VM in DataStore• Use an Administrator account• Web based: localhost 8222 and 8333 (SSL)

Setup• Host OS: XP Pro 32-bit SP3, 64-bit Vista SP1• Guest OS: Oracle Enterprise Linux 5 32-bit• Host: localhost• Guest Machines: tintin and haddock• Database: snowy, Oracle 10.2.0.4 32-bit

Page 6: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 6 / 43

VMware::Network SetupWINDOWS hosts file:• c:\windows\system32\drivers\etc\hosts

Linux hosts file:• /etc/hosts

hosts entries:# Windows Host Entries127.0.0.1 localhost::1 localhost

# Linux VM Host (Guest) Entries / Listener fails to start without this entry127.0.0.1 localhost.localdomain localhost

# Dataguard VMware Configuration on all hosts192.168.196.1 me me.ahgvm.me192.168.196.2 tintin tintin.ahgvm.me192.168.196.3 haddock haddock.ahgvm.me

10.0.0.1 me-pri me-pri.ahgvm.me10.0.0.2 tintin-pri tintin-pri.ahgvm.me snowy-a snowy-a.ahgvm snowy-a.ahgvm.me10.0.0.3 haddock-pri haddock-pri.ahgvm.me snowy-b snowy-b.ahgvm snowy-b.ahgvm.me

Page 7: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 7 / 43

Dataguard::Transports Log Transport Mechanisms:

• log_archive_dest_n• SERVICE• ARCH or LGWR• SYNC, ASYNC=[size]• AFFIRM, NOAFFIRM

• log_archive_dest_state_n• enable• defer• reset• alternate

Log Transport Modes:• MAXIMUM PERFORMANCE

• Transport: ARCH or LGWR• Transmission: ASYNC if using LGWR• If using ASYNC standby redo logs needed• Standby Disk writes: NOAFFIRM• Primary does not stop if standby unavailable

• MAXIMUM AVAILABILITY• Transport: LGWR• Transmission: SYNC• Standby Disk writes: AFFIRM (1 standby)• Requires Standby Redo Logs • (online redo group count + 1)*threads• Does not stop if redo not written to >= 1

standby• Downgrades to MAXIMUM PERFORMANCE

• MAXIMUM PROTECTION• Transport: LGWR• Transmission: SYNC• Standby Disk Writes: AFFIRM• Requires Standby Redo Logs• (online redo group count + 1)*threads• Hangs if redo not written to >= 1 standby• Eventual Shutdown

MAX PERF MAX AVAIL MAX PROT

REDO ARCHLGWR

LGWR LGWR

SYNC SYNCASYNC

SYNC SYNC

WRITE AFFIRMNOAFFIRM

AFFIRM AFFIRM

STBY REDO

NO YES YES

Page 8: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 8 / 43

Dataguard::Transport Parameters Additional Parameters:

• MANDATORY, OPTIONAL• ALTERNATE=[log_archive_dest_n], NOALTERNATE• DEPENDENCY=[log_archive_dest_n], NODEPENDENCY• MAX_FAILURE=[number_of_retries], NOMAX_FAILURE• REOPEN=[seconds] default 60, NOREOPEN• DELAY=[minutes], default 30, NODELAY• NET_TIMEOUT=[seconds], NONET_TIMEOUT• VERIFY, NOVERIFY (with ARCH transport only)• DB_UNIQUE_NAME=[targetdb unique name], NODB_UNIQUE_NAME• VALID_FOR=(redo_log_type, database_role)

• redo_log_type: online_logfile, standby_logfile, all_logfiles• database_role: primary_role, standby_role, all_roles

• log_archive_config='dg_config=(snowy_a,snowy_b)‘• archive_lag_target=(x+y)

• x: current redo log created x seconds ago• y: estimated archival time for current log’s redo• redo log switch when ((x+y) > archive_lag_target) and (redo entries exist))

• fal_client• fal_server

Setting Protection Levels:• Add standby redo logs for MAX PROTECTION & MAX AVAILABILITY• STARTUP MOUNT;• ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE

{PROTECTION | AVAILABILITY | PERFORMANCE};• Open DB

Page 9: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 9 / 43

DB

STANDBY DB

Dataguard::LGWR Transport Primary Processes

• LGWR• LNSn (LGWR Network Server Process)

Standby Processes• RFS (Remote File Server Process)• MRP (Managed Recovery Process)• ARCn

DB

PRIMARY DB

Archive Logs

ARCn

a1

a2

a3

Redo logs

r1

LGWR

r3

r2Archive Logs

ARCn

a1

a2

a3Standby Redo logs

r1

RFS

r3

r2LNSn

MRP

Page 10: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 10 / 43

FSFO Architecture

DB

PRIMARY

Redo logs

LGWR LNSn

DB

STANDBY

MRP

Real-TimeApply

Standby Redo logs

RFS

OBSERVER

OBSERVER

DMON DMON

BrokerCfg.

BrokerCfg.

spfile spfile

Page 11: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 11 / 43

FSFO RequirementsDGMGRL listener serviceDGMGRL TNS uses serviceStandby Redo LogsFlashback DatabaseProtection Level: MAX AVAILABILITYReal-Time ApplyBroker ConfigurationConversion to spfileCreate DGMGRL ConfigurationObserver

Page 12: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 12 / 43

DGMGRL listener serviceDedicated Dataguard ListenersAdd DGMGRL service entriesUse db_unique_name in service

entries

Page 13: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 13 / 43

DGMGRL listener servicelsnr_snowy_dg_001 = (description = (address_list= (address=(protocol=tcp) (host=snowy-a.ahgvm.me) (port=5701)) ))

sid_list_lsnr_snowy_dg_001 = (sid_list= (sid_desc=(sdu=32767) (sid_name = snowy) (oracle_home = /orah/oracle/10204) ) )

sid_list_lsnr_snowy_dg_001 = (sid_list= (sid_desc=(sdu=32767) (sid_name = snowy) (oracle_home = /orah/oracle/10204) ) (sid_desc=(sdu=32767) (sid_name = snowy) (oracle_home = /orah/oracle/10204) (global_dbname = snowy_a_DGMGRL.ahgvm) ) )

lsnr_snowy_dg_001 = (description = (address_list= (address=(protocol=tcp) (host=snowy-b.ahgvm.me) (port=5703)) ))

sid_list_lsnr_snowy_dg_001 = (sid_list= (sid_desc=(sdu=32767) (sid_name = snowy) (oracle_home = /orah/oracle/10204) ) )

sid_list_lsnr_snowy_dg_001 = (sid_list= (sid_desc=(sdu=32767) (sid_name = snowy) (oracle_home = /orah/oracle/10204) ) (sid_desc=(sdu=32767) (sid_name = snowy) (oracle_home = /orah/oracle/10204) (global_dbname = snowy_b_DGMGRL.ahgvm) ) )

Page 14: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 14 / 43

DGMGRL listener registrationdb_unique_name=snowy_a

local_listener='(address_list= (address= (protocol=tcp) (host=snowy-a.ahgvm.me) (port=5701) ) (address= (protocol=tcp) (host=snowy-a.ahgvm.me) (port=5702) ))'

db_unique_name=snowy_b

local_listener='(address_list= (address= (protocol=tcp) (host=snowy-b.ahgvm.me) (port=5703) ) (address= (protocol=tcp) (host=snowy-b.ahgvm.me) (port=5704) ))‘

Page 15: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 15 / 43

Application listener FQDNFQDN (Fully Qualified Domain Name)HostnameApplication Listeners started

lsnr_snowy_general = (address= (protocol=tcp) (host=snowy-cname.ahgvm.me) (port=1526) )

lsnr_snowy_general = (address= (protocol=tcp) (host=snowy-a.ahgvm.me) (port=1526) )

lsnr_snowy_general = (address= (protocol=tcp) (host=snowy-cname.ahgvm.me) (port=1526) )

lsnr_snowy_general = (address= (protocol=tcp) (host=snowy-b.ahgvm.me) (port=1526) )

Page 16: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 16 / 43

DGMGRL TNS uses serviceDGMGRL TNS entryUse unique DGMGRL service names

snowy_a.ahgvm = (DESCRIPTION = (SDU = 32767) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = snowy-a.ahgvm.me) (PORT = 5701) ) (ADDRESS = (PROTOCOL = TCP) (HOST = snowy-a.ahgvm.me) (PORT = 5702) ) ) (CONNECT_DATA = (SERVICE_NAME = snowy_a_DGMGRL.ahgvm) (SERVER = DEDICATED) ) )

snowy_b.ahgvm = (DESCRIPTION = (SDU = 32767) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = snowy-b.ahgvm.me) (PORT = 5703) ) (ADDRESS = (PROTOCOL = TCP) (HOST = snowy-b.ahgvm.me) (PORT = 5704) ) ) (CONNECT_DATA = (SERVICE_NAME = snowy_b_DGMGRL.ahgvm) (SERVER = DEDICATED) ) )

Page 17: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 17 / 43

Application TNSApplication TNS uses CNAMECNAME needs to be flipped

snowy.ahgvm = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = snowy-cname.ahgvm.me) (PORT = 1526) ) ) ) (CONNECT_DATA = (SERVICE_NAME = snowy) (SERVER = DEDICATED) ) )

snowy.ahgvm = (DESCRIPTION = (FAILOVER = ON)(LOAD_BALANCE=OFF) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = snowy-a.ahgvm.me) (PORT = 1526) ) (ADDRESS = (PROTOCOL = TCP) (HOST = snowy-b.ahgvm.me) (PORT = 1526) ) ) (CONNECT_DATA = (SERVICE_NAME = snowy) (SERVER = DEDICATED) ) ) UNTESTED

Page 18: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 18 / 43

Standby Redo LogsPrimary and StandbySame size as Online RedoStandby Groups ≥ Online Groups + 1Standby Groups not mutliplexedRealtime Apply requirementMAXIMUM AVAILABILITY requirement

Page 19: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 19 / 43

Standby Redo Logs

SQL> select type as "Types", count(distinct group#) as "Groups" from v$logfile group by type;

Types Groups------- ----------ONLINE 3

SQL> select a.group#, a.type, b.status, a.member, b.bytes/power(2,20) from v$logfile a, v$log b where a.group# = b.group# ;

Group Type       Status     Log File                       Size/MB----- ---------- ---------- ------------------------------ -------    1 ONLINE     CURRENT    /dbh/snowy/redo1/redo1a.log         50    1 ONLINE     CURRENT    /dbh/snowy/redo2/redo1b.log         50    2 ONLINE     INACTIVE   /dbh/snowy/redo2/redo2a.log         50    2 ONLINE     INACTIVE   /dbh/snowy/redo3/redo2b.log         50    3 ONLINE     INACTIVE   /dbh/snowy/redo3/redo3a.log         50    3 ONLINE     INACTIVE   /dbh/snowy/redo1/redo3b.log         50

Count and Size of Online Redo Groups

Page 20: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 20 / 43

Standby Redo Logs

alter database add standby logfile group 4 '/dbh/snowy/redo1/red04a.log' size 50M;

alter database add standby logfile group 5 '/dbh/snowy/redo1/red05a.log' size 50M;

alter database add standby logfile group 6 '/dbh/snowy/redo1/red06a.log' size 50M;

alter database add standby logfile group 7 '/dbh/snowy/redo1/red07a.log' size 50M;

alter database add standby logfile group 8 '/dbh/snowy/redo1/red08a.log' size 50M;

alter database add standby logfile group 9 '/dbh/snowy/redo1/red09a.log' size 50M;

Add Standby Redo (Primary & Standby)Three online groups in exampleNeed at least 3+1 = 4 standby groupsHave 3 file systems in exampleAdding 6 standby groups > 4

Page 21: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 21 / 43

Flashback DatabaseParameters

• db_recovery_file_dest=/dbh/flashback• db_recovery_file_dest_size=3G• db_flashback_retention_target=60

Flashback Sizing• Redo generated in db_flashback_retention_target seconds• Sufficient space in db_recovery_file_dest_size • db_unique_name sub-directory automatically created under

db_recovery_file_dest

V$DATABASE • FLASHBACK_ON

Enable Flashback Primary / Standby• STARTUP MOUNT• ALTER DATABASE FLASHBACK ON

Page 22: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 22 / 43

Prot. Level: MAX AVAILABILITYDestination Options Primary & Standby• LGWR• SYNC• AFFIRM

V$ARCHIVE_DEST• ARCHIVER• TRANSMIT_MODE• AFFIRM

db_unique_name=snowy_a

log_archive_dest_2 = 'db_unique_name=snowy_b SERVICE=snowy_b valid_for=(online_logfile, primary_role) REOPEN=60 OPTIONAL LGWR SYNC AFFIRM'

db_unique_name=snowy_b

log_archive_dest_2 = 'db_unique_name=snowy_a SERVICE=snowy_a valid_for=(online_logfile, primary_role) REOPEN=60 OPTIONAL LGWR SYNC AFFIRM'

Page 23: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 23 / 43

Prot. Level: MAX AVAILABILITY

Primary & Standby• STARTUP MOUNT• ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE

AVAILABILITY;

V$DATABASE• PROTECTION_MODE

Page 24: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 24 / 43

Real Time ApplyStarted on StandbyRedo applied directly FSFO Starts AutomaticallySYNTAX• ALTER DATABASE RECOVER MANAGED STANDBY

DATABASE PARALLEL n USING CURRENT LOGFILE DISCONNECT FROM SESSION;

Archive Log Entries:• “Managed Standby Recovery not using Real Time Apply”• “Managed Standby Recovery starting Real Time Apply”

Page 25: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 25 / 43

Broker ConfigurationPrimary & Standby• dg_broker_start=false• Change to true after spfile conversion and restart• Setting to true starts DMON process• DMON log in background_dump_dest -> drc<SID>.log• snowy -> drcsnowy.log

Primary• dg_broker_config_file1='/orah/oracle/admin/snowy/pfile/snowy_a_broker_1.dat‘• dg_broker_config_file2='/orah/oracle/admin/snowy/pfile/snowy_a_broker_2.dat'

Standby• dg_broker_config_file1='/orah/oracle/admin/snowy/pfile/snowy_b_broker_1.dat‘• dg_broker_config_file2='/orah/oracle/admin/snowy/pfile/snowy_b_broker_2.dat'

Page 26: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 26 / 43

Conversion to spfileObserver updates db parameters via.

DMON process on Primary & Standby spfile requiredKeep last known good pfileV$SPPARAMETERPrimary & StandbySQL> create spfile=‘/orah/oracle/admin/snowy/pfile/spfilesnowy.ora’ from pfile;SQL> SHUTDOWN IMMEDIATE;

$ cd $ORACLE_HOME/dbs$ mv initsnowy.ora initsnowy.pfile$ echo “spfile=/orah/oracle/admin/snowy/pfile/spfilesnowy.ora” > initsnowy.ora

SQL> /* STARTUP OPEN on PRIMARY, STARTUP MOUNT on STANDBY */SQL> alter system set dg_broker_start= true scope=both;

Page 27: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 27 / 43

Create DGMGRL Configurationspfile in use & dg_broker_start=truePrimary:$ORACLE_HOME/bin/dgmgrl /DGMGRL for Linux: Version 10.2.0.4.0 – ProductionCopyright (c) 2000, 2005, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.Connected.

DGMGRL> create configuration 'FSFOsnowy' as> primary database is 'snowy_a'> connect identifier is snowy_a.ahgvm;Configuration "FSFOsnowy" created with primary database "snowy_a"

DGMGRL> add database 'snowy_b' as> connect identifier is snowy_b.ahgvm> maintained as physical;Database "snowy_b" added

Page 28: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 28 / 43

Show DGMGRL ConfigurationDGMGRL> show configuration

Configuration Name: FSFOsnowy Enabled: NO Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: snowy_a - Primary database snowy_b - Physical standby database

Current status for "FSFOsnowy":DISABLED

Page 29: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 29 / 43

Show snowy_a Configuration IDGMGRL> show database verbose snowy_a

Database Name: snowy_a Role: PRIMARY Enabled: NO Intended State: OFFLINE Instance(s): snowy

Properties: InitialConnectIdentifier = 'snowy_a.ahgvm' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' Dependency = '' DelayMins = '0' Binding = 'OPTIONAL' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '180' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyParallel = 'AUTO' StandbyFileManagement = 'auto' ArchiveLagTarget = '0’

Continues on Next Slide

Page 30: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 30 / 43

Show snowy_a Configuration II ArchiveLagTarget = '0' LogArchiveMaxProcesses = '2' LogArchiveMinSucceedDest = '1' DbFileNameConvert = '' LogFileNameConvert = ' , ' FastStartFailoverTarget = '' StatusReport = '(monitor)' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' HostName = 'tintin.ahgvm.me' SidName = 'snowy' LocalListenerAddress = '(address=(protocol=tcp)(host=snowy-a.ahgvm.me)(port=5701))' StandbyArchiveLocation = 'dgsby_snowy_a' AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = 'snowy-%t_%s_%r.arc' LatestLog = '(monitor)' TopWaitEvents = '(monitor)'

Current status for "snowy_a":DISABLED Continued from

Last Slide

Page 31: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 31 / 43

Edit snowy_a PropertiesDGMGRL> edit database snowy_a set property 'LogXptMode'='SYNC';Property "LogXptMode" updatedDGMGRL> edit database snowy_a set property 'NetTimeout'='10';Property "NetTimeout" updatedDGMGRL> edit database snowy_a set property 'StandbyArchiveLocation'='/dbh/snowy/arch';Property "StandbyArchiveLocation" updated

DGMGRL> show database verbose snowy_a

Database Name: snowy_a Role: PRIMARY Enabled: NO Intended State: OFFLINE Instance(s): snowy

Properties: .... LogXptMode = 'SYNC‘ .... NetTimeout = '10‘ .... StandbyArchiveLocation = '/dbh/snowy/arch‘ ....

Current status for "snowy_a":DISABLED

Page 32: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 32 / 43

Edit snowy_b PropertiesDGMGRL> edit database snowy_b set property 'LogXptMode'='SYNC';Property "LogXptMode" updatedDGMGRL> edit database snowy_b set property 'NetTimeout'='10';Property "NetTimeout" updated

DGMGRL> show database verbose snowy_b

Database Name: snowy_b Role: PHYSICAL STANDBY Enabled: NO Intended State: OFFLINE Instance(s): snowy

Properties: .... LogXptMode = 'SYNC' .... NetTimeout = '10‘ .... StandbyArchiveLocation = '/dbh/snowy/arch/' ....

Current status for "snowy_b":DISABLED

Page 33: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 33 / 43

Enable ConfigurationDGMGRL> enable configurationEnabled.

DGMGRL> show configuration

Configuration Name: FSFOsnowy Enabled: YES Protection Mode: MaxAvailability Fast-Start Failover: DISABLED Databases: snowy_a - Primary database snowy_b - Physical standby database

Current status for "FSFOsnowy":SUCCESS

Current status for "FSFOsnowy":Warning: ORA-16610: command 'Broker automatic health check' in progress

Current status for "FSFOsnowy":Warning: ORA-16610: command 'ENABLE DATABASE snowy_b' in progress

Page 34: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 34 / 43

Enable Fast Start FailoverDGMGRL> enable fast_start failover;Enabled.

DGMGRL> show configuration

Configuration Name: FSFOsnowy Enabled: YES Protection Mode: MaxAvailability Fast-Start Failover: ENABLED Databases: snowy_a - Primary database snowy_b - Physical standby database - Fast-Start Failover target

Current status for "FSFOsnowy":SUCCESS

Page 35: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 35 / 43

Check Fast Start Failover

Fast Start Failover Status:============================================================DB_UNIQUE_NAME : snowy_aSWITCHOVER_STATUS : SESSIONS ACTIVEFORCE_LOGGING : YESPROTECTION_MODE : MAXIMUM AVAILABILITYPROTECTION_LEVEL : MAXIMUM AVAILABILITYFLASHBACK_ON : YESFS_FAILOVER_STATUS : SYNCHRONIZEDFS_FAILOVER_OBSERVER_HOST : hulk.ilmtech.comFS_FAILOVER_CURRENT_TARGET : snowy_bFS_FAILOVER_THRESHOLD : 30FS_FAILOVER_OBSERVER_PRESENT : NO

Fast Start Failover Status:============================================================DB_UNIQUE_NAME : snowy_bSWITCHOVER_STATUS : SESSIONS ACTIVEFORCE_LOGGING : YESPROTECTION_MODE : MAXIMUM AVAILABILITYFLASHBACK_ON : YESFS_FAILOVER_STATUS : SYNCHRONIZEDFS_FAILOVER_OBSERVER_HOST : hulk.ilmtech.comFS_FAILOVER_CURRENT_TARGET : snowy_bFS_FAILOVER_THRESHOLD : 30FS_FAILOVER_OBSERVER_PRESENT : NO

fsfo_check.sql (V$DATABASE)

Page 36: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 36 / 43

Observer

dgmgrl sys/oracle@snowyDGMGRL for Linux: Version 10.2.0.4.0 - Production

Copyright (c) 2000, 2005, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.Connected.DGMGRL> start observerObserver started

Run on separate hostPreferably separate data centerForeground processRequires SYSDBA credentialsCreate a wrapper script

Page 37: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 37 / 43

Failover

14:44:29.28 Tuesday, May 19, 2009Initiating fast-start failover to database “snowy_b"...Performing failover NOW, please wait...Failover succeeded, new primary is “snowy_b"14:45:04.03 Tuesday, May 19, 2009

“shutdown abort” on Primary Observer output:

14:46:40.77 Tuesday, May 19, 2009Initiating reinstatement for database “snowy_a"...Reinstating database “snowy_a", please wait...Operation requires shutdown of instance “snowy" on database “snowy_a"Shutting down instance “snowy"...ORA-01109: database not open

Database dismounted.ORACLE instance shut down.Operation requires startup of instance “snowy" on database “snowy_a"Starting instance “snowy"...ORACLE instance started.Database mounted.Continuing to reinstate database “snowy_a" ...Reinstatement of database “snowy_a" succeeded14:47:51.45 Tuesday, May 19, 2009

“startup mount” old Primary, convert to Standby Observer output:

Page 38: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 38 / 43

Switchover DGMGRL connection to Primary or Standby Observer produes no output Issue switchover manually

DGMGRL> switchover to snowy_aPerforming switchover NOW, please wait...Operation requires shutdown of instance "snowy" on database "snowy_b"Shutting down instance "snowy"...ORA-01109: database not open

Database dismounted.ORACLE instance shut down.Operation requires shutdown of instance "snowy" on database "snowy_a"Shutting down instance "snowy"...ORA-01109: database not open

Database dismounted.ORACLE instance shut down.Operation requires startup of instance "snowy" on database "snowy_b"Starting instance "snowy"...ORACLE instance started.Database mounted.Operation requires startup of instance "snowy" on database "snowy_a"Starting instance "snowy"...ORACLE instance started.Database mounted.Switchover succeeded, new primary is "snowy_a"

Page 39: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 39 / 43

Role Trigger : DB_ROLE_CHANGEDB_ROLE_CHANGE fires whenever a

db role changes.Create a trigger that flips the CNAME

after the the trigger fires.role_change_trigger.sql

Page 40: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 40 / 43

Thank You

Ahbaid Gaffoor

ahbaid@{amazon.com|a9.com|att.net}

Page 41: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 41 / 43

References Oracle Documentation:

• http://tahiti.oracle.com• Dataguard Concepts and Administration

Books:• Oracle Database High Availability with RAC, Flashback & Data Guard – Matthew

Hart & Scott Jesse, Oracle Press• Oracle Data Guard – Bipul Kumar, Rampant• Oracle on VMware – Bert Scalzo, Rampant

Sites:• otn.oracle.com• ocpdba.net• orafaq.com• psoug.org• vmware.com

Mailing Lists:• Oracle-L

Page 42: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 42 / 43

declare

cursor cdb is select FORCE_LOGGING, PROTECTION_MODE, PROTECTION_LEVEL, FLASHBACK_ON, DB_UNIQUE_NAME, SWITCHOVER_STATUS, FS_FAILOVER_STATUS, FS_FAILOVER_CURRENT_TARGET, FS_FAILOVER_THRESHOLD, FS_FAILOVER_OBSERVER_PRESENT, FS_FAILOVER_OBSERVER_HOST from v$database;

procedure print(s varchar2) is begin dbms_output.put_line(s); end print; procedure cr is begin print(chr(10)); end cr; procedure line(l number := 60, c varchar2 := '=') is begin print(rpad(c,l,c)); end line;

begin for db in cdb loop cr; print('Fast Start Failover Status:'); line; print(rpad('DB_UNIQUE_NAME',31)||': '||db.DB_UNIQUE_NAME); print(rpad('SWITCHOVER_STATUS',31)||': '||db.SWITCHOVER_STATUS); print(rpad('FORCE_LOGGING',31)||': '||db.FORCE_LOGGING); print(rpad('PROTECTION_MODE',31)||': '||db.PROTECTION_MODE); print(rpad('PROTECTION_LEVEL',31)||': '||db.PROTECTION_LEVEL); print(rpad('FLASHBACK_ON',31)||': '||db.FLASHBACK_ON); print(rpad('FS_FAILOVER_STATUS',31)||': '||db.FS_FAILOVER_STATUS); print(rpad('FS_FAILOVER_OBSERVER_HOST',31)||': '||db.FS_FAILOVER_OBSERVER_HOST); print(rpad('FS_FAILOVER_CURRENT_TARGET',31)||': '||db.FS_FAILOVER_CURRENT_TARGET); print(rpad('FS_FAILOVER_THRESHOLD',31)||': '||db.FS_FAILOVER_THRESHOLD); print(rpad('FS_FAILOVER_OBSERVER_PRESENT',31)||': '||db.FS_FAILOVER_OBSERVER_PRESENT); cr; end loop;end;/

Appendix: fsfo_check.sql

Page 43: DBA’s Guide to Physical Dataguard Part II. DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21 st 2009 2 / 43 Overview

DBA’s Guide to Physical Dataguard Part II, NoCOUG May 21st 2009 43 / 43

create or replace trigger T_FLIP_CNAME after db_role_change on databasedeclare

FLIP_DBCNAME_SCRIPT constant varchar2(100) := '/utilities/flip_dbcname'; DBCNAME_JOB constant varchar2(10) := 'DB_CNAME_FLIP'; dbrole VARCHAR2(30); dbname VARCHAR2(30); e_flip_dbcname_script EXCEPTION; PRAGMA EXCEPTION_INIT (e_flip_dbcname_script, -27369);

begin

select database_role into dbrole from v$database;

if (dbrole = 'PRIMARY') then begin dbms_scheduler.drop_job(ROLE_JOB); exception when others then null; end; dbms_scheduler.create_job( job_name => DBCNAME_JOB, job_type => 'EXECUTABLE', number_of_arguments => 1, job_action => FLIP_DBCNAME_SCRIPT, enabled => false, auto_drop => true ); select instance_name into dbname from v$instance; dbms_scheduler.set_job_argument_value( job_name => DBCNAME_JOB, argument_position => 1, argument_value => dbname); begin dbms_scheduler.run_job(DBCNAME_JOB); exception when e_flip_dbcname_script then raise_application_error(-20001, 'flip failed in ' ||FLIP_DBCNAME_SCRIPT); end; end if;

exception when others then raise_application_error(-20002, 'DB_ROLE_CHANGE trigger failed '||SQLERRM);end;

Appendix: role_change_trigger.sql