Under The Hood of Active Data Guard Author & Presenter: Nassyam Basha Date: 27-FEB-2015
Nassyam Bashaa Post Graduation in computers from University of Madras Oracle Database Consultant @ Pythian Frequent OTN contributor (CKPT) /MOSC certified GURU Co-Author of Oracle 11gR2 Data Guard administration beginners Guide Blogger Author of OTN Articles 11g Oracle Certified Master Co-Founder of @nassyambasha /nassyambasha 2 2014 Pythian
Under The Hood of Active Data Guard Data Guard vs. Active Dataa Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby Applications & ADG 3 2014 Pythian
Data Guard vs. Active Dataa Guard Data Guard Resources are locked Stale results by opening standby in read-only after MRP termination. Active Data Guard Additional License for the usage of Activ ve Data Guard from 11g Improves performance of Primary by offloading queries, reporting with real-time data Complex queries, Sorting, Web-based access while redo apply Read-Only applications Best suits for Enquiries, Tracking statuss (No DML/DDL) Unlocks the resources (System, Storage.) 4 2014 Pythian
Active Data Guard Oracle Net PRIMARY DATABASE LGWR NSS/ NSA RFS STANDBY DATABASE ORL s SRL s ARC H ARC H 5
Data Guard Real Time apply is applicable No Real-Time Queries, Database will be in Mount Status 6 2014 Pythian
Under The Hood of Active Data Guard Data Guard vs. Active Data Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby & Applications Applications & ADG 7 2014 Pythian
Set up of ADG Compatible=11.0.0 Ensure Real-Time apply is On. Uncomplicated procedure Broker manages everything to bounce MRP Standby can be RAC or non-rac and Broker is supported. 8
Under The Hood of Active Data Guard Data Guard vs. Active Data Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby & Applications Applications & ADG 9 2014 Pythian
Real Time Query Here you go 10
Real-Time Query Validation Monitoring data apply on standby database to track real-time apply 11
Real-Time Query Test No scope for the stale data 12
Guarantee Data Currency SESSION_MAX_DATA_DELAY parameter applicable only for non-administrator users Session specific apply lag tolerance If session_max_data_delay set to None, query results regardless of the apply lag with primary database. Standby SQL> connect c##nassyam/oracle@india; Connected. SQL> alter session set standby_max_data_delay= =30; Session altered. DGMGRL> edit database india set state='apply-o OFF'; Succeeded. DGMGRL> Primary SQL> set time on 07:59:01 SQL> insert into adg_table values (150, 'PUNE'); 1 row created. 07:59:14 SQL> commit; Commit complete. 13
Guarantee Data Currency Standby SQL> select count(*) from adg_table; select count(*) from adg_table * ERROR at line 1: ORA-00604: error occurred at recursive SQL level 2 ORA-03172: STANDBY_MAX_DATA_DELAY of 30 seconds exceeded 14
Guarantee Data Currency SQL> select name,value from v$dataguard_stats; NAME VALUE -------------------------------- ------------------------------ transport lag +00 00:00:00 apply lag +00 00:14:55 apply finish time estimated startup time 13 To avoid stale data for any specific triggers with parameter standby_max_delay works. CREATE OR REPLACE TRIGGER max_data_delay AFTER LOGON ON database BEGIN IF (SYS_CONTEXT( USERENV, DATABASE_ROLE ) in ( PHYSICAL STANDBY ) and SYS_CONTEXT( USERENV, SESSION_USER )= C## #NASSYAM ) THEN execute immediate ALTER SESSION SET STANDBY_MAX_DATA_DELAY=5; END IF; END; / 15
Under The Hood of Active Data Guard Data Guard vs. Active Data Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby & Applications Applications & ADG 16 2014 Pythian
Gap Detection and Resolution Missing redo stream with full log file or into parts Network Outage Deletion or Missing of log files before they applied on standby Bad configuration Can be FRA, Corruption, Data files issue Consider reviewing the alert log and views v$archived_log, v$archive_gap, v$archive_dest, v$database, v$dataguard_status, v$managed_standby, v$log_history Resolution: Resolution not required for Good configuration, Oracle take cares in resolving GAP by RFS FAL parameter 17
Under The Hood of Active Data Guard Data Guard vs. Active Data Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby & Applications Applications & ADG 18 2014 Pythian
Block Change Tracking BCT can quickly identifies the blocks changes since last backup. BCT on Standby supported from 11.2 Many bugs with 11.2 < 11gR2 CTWR cannot write in BCT when recovery in progress. 19
Block Change Tracking BCT works only on Incremental backups 20
Under The Hood of Active Data Guard Data Guard vs. Active Data Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby & Applications Applications & ADG 21 2014 Pythian
Automatic Block Repair Automatic Block repair feature of ADG from 11g Media recovery works in 2-way Real-Time query should be working. Automatically repairs physical corruption. Increases availability and maintaining data protection all time. PRIMARY DATABASE STANDBY DATABASE 22
Automatic Block Repair Without ADG SQL> select count(*) from c##nassyam.adg_table; select count(*) from c##nassyam.adg_table * ERROR at line 1: ORA-01578: ORACLE data block corrupted (file # 6, block # 354) ORA-01110: data file 6: '/u02/app/oracle/oradata/mcdb/users01.dbf' With the power of ADG SQL> select count(*) from C##NASSYAM.ADG_TABLE; COUNT(*) ---------- 3 Reading datafile '/u02/app/oracle/oradata/mcdb/users01.dbf' for corruption at rdba: 0x01800164 (file 6, block 356) Reread (file 6, block 356) found same corrupt data (no o logical check) Automatic block media recovery requested for (file# 6,, block# 356) Sat Feb 21 22:24:07 2015 Automatic block media recovery successful for (file# 6, block# 356) Sat Feb 21 22:24:07 2015 Automatic block media recovery successful for (file# 6, block# 355) Sat Feb 21 22:24:07 2015 Automatic block media recovery successful for (file# 6, block# 355) Automatic block media recovery successful for (file# 6, block# 356) 23
Under The Hood of Active Data Guard Data Guard vs. Active Data Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby & Applications Applications & ADG 24 2014 Pythian
Tuning Reports: Statspack With ADG we can measure performance by interpreting Tuning tools Statspack on standby is available from 11gR1 Before using Statspack, must have schema and Statspack related objects, If not available they can created using spcreate.sql Statspack Installation SQL> alter session set "_oracle_script"= =true; SQL> @?/rdbms/admin/spcreate Standby Statspack Installation, creates STDBYPERF user for Standby. SQL> @?/rdbms/admin/sbcreate.sql Add additional Standby from STDBYPERF user SQL> @?/rdbms/admin/sbaddins Creating Snapshot Manually (exec statspack_<db_unique_name>_<instance_name>.snap) SQL> exec statspack_india_drmcdb.snap Generate Statspack report(test case) from STDBYPERF user SQL> exec statspack_india_drmcdb.snap SQL> @?/rdbms/admin/sbreport 25
Tuning Reports: Sample Statspack Report ADG allows more scope to review performance of standby database also. D:\All Oracle\ unity & User Group 26
Tuning Reports: ASH Report ASH report is very useful to track active sessions and also Historical. Ability to generate reports same as Primary with HTML and Text based. SQL> select db_unique_name,database_role from v$database; DB_UNIQUE_NAME DATABASE_ROLE -------------------- ---------------- india PHYSICAL STANDBY SQL> @?/rdbms/admin/ashrpt.sql Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instance ----------- ------------ -------- ------------- 3793852408 MCDB 1 drmcdb... You are running ASH report on a Standby database. To generate the report over data sampled on the Primary database, enter 'P'. Defaults to 'S' - data sampled in the Standby database. Enter value for stdbyflag: S Using Primary (P) or Standby (S): S 27
Tuning Reports: ASH Report ASH report is very useful to track active sessions and also Historical. 28
Under The Hood of Active Data Guard Data Guard vs. Active Data Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby & Applications Applications & ADG 29 2014 Pythian
Exporting Data from Standby Creates only master table at Primary database Disk reads, Memory consumption of processes from standby database. SQL>!mkdir -p /home/oracle/working/nassyam/ SQL> create or replace directory exp_adg as '/home/oracle/working/nassyam'; Directory created. SQL> grant read,write,execute on directory exp_adg to public; Grant succeeded. SQL> create public database link exp_adg connect to system identified by oracle using 'india'; Database link created. SQL> 30
Exporting Data from Standby -bash-3.2$ expdp system/oracle directory=exp_adg dumpfile=exp_full.dmp logfile=exp_full.log schemas= c##nassyam network_link=exp_adg Export: Release 12.1.0.1.0 - Production on Fri Feb 20 18:03:59 2015 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0-64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options WARNING: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database. Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01": system/*** ****** directory=exp_adg dumpfile=exp_full.dmp logfile=exp_full.log schemas= network_link=exp_adg Estimate in progress using BLOCKS method... Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATAA Total estimation using BLOCKS method: 247.0 MB Processing object type SCHEMA_EXPORT/USER Processing object type SCHEMA_EXPORT/SYSTEM_GRANT Processing object type SCHEMA_EXPORT/ROLE_GRANT Processing object type SCHEMA_EXPORT/DEFAULT_ROLE Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Processing object type SCHEMA_EXPORT/TABLE/TABLE Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS Processing object type SCHEMA_EXPORT/STATISTICS/MARKER.. exported "C##NASSYAM"."TEST_UPDATE" 208.7 MB 4000000 rows.. exported "C##NASSYAM"."ADG_TABLE" 6.179 KB 3 rows Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded ****************************************************************************** Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is: /home/oracle/working/nassyam/exp_full.dmp Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully co ompleted at Fri Feb 20 18:05:59 2015 elapsed 0 00:01:57 31
Under The Hood of Active Data Guard Data Guard vs. Active Data Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby Applications & ADG 32 2014 Pythian
DML s on Standby & Applications Active Data Guard feature from 12.1.0.1 Key Parameter: TEMP_UNDO_ENABLED(Dynamic) Compatible parameter should be 12.0.0 DDL s should be issued from Primary Transactions splits, Temporary objects will be used temporary undo and normal objects in Permanent undo. SQL> create global temporary table ADG_GTT on commit preserve rows as select * from testobj; Table created. DDL only on Primary SQL> SQL> conn c##nassyam/oracle Connected. SQL> select count(*) from adg_gtt; COUNT(*) ---------- 0 SQL> insert into ADG_GTT select * from testobj; DML on Standby 91431 rows created. SQL> select count(*) from adg_gtt; New rows on Standby COUNT(*) ---------- 91431 33
DML s on Standby & Applications 12 New feature SQL> set autotrace traceonly statistics; SQL> insert into ADG_GTT select * from testobj; 91431 rows created. Statistics ---------------------------------------------------------- 312 recursive calls 8499 db block gets 3542 consistent gets 1534 physical reads 0 redo size 854 bytes sent via SQL*Net to client 841 bytes received via SQL*Net from client 3 SQL*Net roundtrips to/from client 35 sorts (memory) 0 sorts (disk) 91431 rows processed SQL> select count(*) from adg_gtt; COUNT(*) ---------- 182862 34
Under The Hood of Active Data Guard Data Guard vs. Active Data Guard Setup of ADG Real-Time Query Gap Detection and Resolution BCT & Fast Incremental Backups Automatic Block Repair Statspack & ASH Exporting Data from ADG DML s on Standby Applications & ADG 35 2014 Pythian
Applications & ADG Key role is compatibility of applications Peoplesoft EBS 8.5.1 Nvision reports are supported to use and run on ADG Nvisions are mostly select queries(ps_ledger, PS_LEDGER_BUDG) Reports can run from modules FIN, HR, or EPM(DWH). Database Links to access primary system for DML/DDL using triggers Top Links(FMW) Oracle BI(10.1.3.4) SAP does not work with ADG with ADG 36
Finally These all are with single License 37
Thank you and Q&A basha@pythian.com @nassyambasha www.oracle-ckpt.com 38