DBA's Guide To Physical Dataguard II
DBA's Guide To Physical Dataguard II
Overview
Recap from Part I Standby Database Physical Standby Dataguard Configuration Protection Levels Dataguard Config & Recap Switchover Fast Start Failover MAXIMUM AVAILABILITY Flashback Database Broker Configuration Anything else
2 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Standby Database
Archive Logs
a1 a2
apply
DB
Redo logs
Archive Logs
STANDBY DB
r1
r2
a1
a2
arc0
DB
lgwr
r3 r4
a3
PRIMARY DB 3 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Dataguard::Overview
Manual Transport Manual Apply Disconnected Manual Switch/Fail over Oracle Transport ARCH LGWR Automatic Apply Connected Broker FSFO Faster Switch/Fail over Protection Levels MAX PERFORMANCE MAX AVAILABILITY MAX PROTECTION
4 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
VMware::Overview
DataStore Directory Create / Import VM in DataStore Use an Administrator account Web based: localhost 8222 and 8333 (SSL)
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
5 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
VMware::Network Setup
c:\windows\system32\drivers\etc\hosts /etc/hosts
# Windows Host Entries 127.0.0.1 localhost ::1 localhost # Linux VM Host (Guest) Entries / Listener fails to start without this entry 127.0.0.1 localhost.localdomain localhost # Dataguard VMware Configuration on all hosts 192.168.196.1 me 192.168.196.2 tintin 192.168.196.3 haddock 10.0.0.1 10.0.0.2 10.0.0.3 me-pri tintin-pri haddock-pri me-pri.ahgvm.me tintin-pri.ahgvm.me haddock-pri.ahgvm.me me.ahgvm.me tintin.ahgvm.me haddock.ahgvm.me snowy-a snowy-a.ahgvm snowy-a.ahgvm.me snowy-b snowy-b.ahgvm snowy-b.ahgvm.me
6 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Dataguard::Transports
log_archive_dest_n SERVICE ARCH or LGWR SYNC, ASYNC=[size] AFFIRM, NOAFFIRM log_archive_dest_state_n enable defer reset alternate
MAX PERF
REDO
SYNC
WRITE
STBY REDO
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
7 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Dataguard::Transport 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 logs redo redo log switch when ((x+y) > archive_lag_target) and (redo entries exist)) fal_client fal_server Add standby redo logs for MAX PROTECTION & MAX AVAILABILITY STARTUP MOUNT; ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE {PROTECTION | AVAILABILITY | PERFORMANCE}; Open DB
8 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Dataguard::LGWR Transport
LGWR LNSn (LGWR Network Server Process)
RFS
MRP
RFS (Remote File Server Process) MRP (Managed Recovery Process) ARCn
DB
r1 a1 a2
ARCn
LNSn
r2
r3
DB
LGWR
r1 r2
r3
ARCn
a1 a2 a3
Archive Logs
a3
Archive Logs
STANDBY DB
Redo logs
PRIMARY DB 9 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
FSFO Architecture
DMON OBSERVER DMON
Broker Cfg.
OBSERVER
Broker Cfg.
DB
LGWR
spfile
spfile
DB
LNSn
RFS
MRP
PRIMARY
STANDBY
10 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
FSFO Requirements
11 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
12 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
13 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
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) ) )
14 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
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) )
15 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
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) ) )
16 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Application TNS
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
17 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
18 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
50 50 50 50 50 50
19 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
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;
20 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Flashback Database
db_recovery_file_dest=/dbh/flashback db_recovery_file_dest_size=3G db_flashback_retention_target=60
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
FLASHBACK_ON
21 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
22 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
PROTECTION_MODE
23 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE PARALLEL n USING CURRENT LOGFILE DISCONNECT FROM SESSION; Managed Standby Recovery not using Real Time Apply Managed Standby Recovery starting Real Time Apply
24 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Broker Configuration
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
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'
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'
25 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Conversion to spfile
SQL> /* STARTUP OPEN on PRIMARY, STARTUP MOUNT on STANDBY */ SQL> alter system set dg_broker_start= true scope=both;
26 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
$ORACLE_HOME/bin/dgmgrl / DGMGRL 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> 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
27 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
28 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
29 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
30 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
31 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
32 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Enable Configuration
DGMGRL> enable configuration Enabled. 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
33 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
34 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
35 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Observer
dgmgrl sys/oracle@snowy DGMGRL 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 observer Observer started
36 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Failover
14:44:29.28 Tuesday, May 19, 2009 Initiating 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
14:46:40.77 Tuesday, May 19, 2009 Initiating 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" succeeded 14:47:51.45 Tuesday, May 19, 2009
37 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Switchover
DGMGRL> switchover to snowy_a Performing 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"
38 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
39 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Thank You
Ahbaid Gaffoor ahbaid@{amazon.com|a9.com|att.net}
40 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
References
http://tahiti.oracle.com Dataguard Concepts and Administration
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
Oracle-L
41 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Appendix: fsfo_check.sql
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; /
42 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009
Appendix: role_change_trigger.sql
create or replace trigger T_FLIP_CNAME after db_role_change on database declare 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;
43 / 43
DBAs Guide to Physical Dataguard Part II, NoCOUG May 21st 2009