Your SlideShare is downloading. ×
0
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
2009 Collaborate IOUG Presentation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

2009 Collaborate IOUG Presentation

365

Published on

Are You Using Flashback Yet?

Are You Using Flashback Yet?

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
365
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Are You Using Flashback Yet? Biju Thomas OneNeck IT Services Corporation http://www.oneneck.com (Booth 4364) Session #330
  • 2. About the Speaker• Senior Database Administrator at OneNeck IT Services Corporation (www.oneneck.com)• More than 15 years of Oracle experience• Author of OCA Oracle Database 11g Administrator Certified Associate Study Guide published by Sybex• Co-author of Oracle10g, Oracle9i & Oracle8i Certification books published by Sybex• Published articles in Oracle Magazine, Oracle Internals and Select Journal• Oracle 11g, 10g, 9i, 8i & 7.3 OCP Administrator
  • 3. Introducing OneNeck The ERP Outsourcing Experts Provide a comprehensive, flexible suite of outsourcing solutions designed specifically to help mid-market and public sector organizations • Supporting over 22,000 users at over 850 sites worldwide • Primary data center/support center operations in Phoenix and Houston • Hosting and managing over 2000 databases • 98% Contract Renewal Rate over 10 years • 100% US based operations and staff • 24x7x365 support center handling over 50,000 tickets annually • Oracle certified hosting partner • Ranked #1 ERP Outsourcing Vendor by the Black Book of Outsourcing three years in a row • http://www.OneNeck.com • Stop by booth 4364
  • 4. Please remember to complete the session evaluation form Biju Thomas Are you using Flashback yet? Session # 330
  • 5. Objectives• Flashback Operations in Oracle Database• What is Flash Recovery Area (FRA)?• Configuring FRA• Flashback Database• Using & Maintaining FRA• V$ Views for FRA and Flashback logs
  • 6. Flashback Operations in Oracle
  • 7. Flashback Query• Introduced in Oracle 9i R1• Use DBMS_FLASHBACK package to enable and disable flashback• Must use Automatic Undo Management• Only DML operations• PL/SQL recognizes flashbackEXECUTE DBMS_FLASHBACK.ENABLE_AT_SYSTEM_CHANGE_NUMBER (n);EXECUTE DBMS_FLASHBACK.ENABLE_AT_TIME (‘date_time‘);EXECUTE DBMS_FLASHBACK.DISABLE;
  • 8. Flashback Query #2• Improvement in 9i R2• AS OF TIMESTAMP and AS OF SCN clauses in query• SYS user can use this clauseExamples:INSERT INTO employeesSELECT * FROM employees as of timestampTO_TIMESTAMP(22-MAR-09 21:50, DD-MON-YY HH24:MI)WHERE employee_id = 106;EXP Parameter:FLASHBACK_SCN=nnnFLASHBACK_TIME="YYYY-MM-DD HH24:MI:SS" [9i fixed format]FLASHBACK_TIME="TO_TIMESTAMP(31-MAR-09 12:00, DD-MON-YY HH24:MI)" [specify format 10g onwards]
  • 9. Flashback Query #3• Example: Rows updated in EMPLOYEES table.SELECT employee_id, first_name, last_name, salaryFROM employees AS OF TIMESTAMPTO_TIMESTAMP(22-MAR-09 21:50, DD-MON-YY HH24:MI)MINUSSELECT employee_id, first_name, last_name, salaryFROM employees;EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY----------- ------------- ---------------- ---------- 103 Alexander Hunold 9000 106 Valli Pataballa 4800
  • 10. Flashback Versions Query• Introduced in Oracle 10g R1• Shows all changes between a timeframeVERSIONS BETWEEN [TIMESTAMP/SCN] .. AND ..• Upper/Lower bound may be replaced with MINVALUE and MAXVALUE to retrieve all available data• VERSIONS_ pseudo columns available – STARTTIME, STARTSCN, ENDTIME, ENDSCN, XID, OPERATION
  • 11. Flashback Versions Query #2• Example:SELECT last_name, versions_starttime, versions_endtime, versions_operationFROM employees VERSIONS BETWEEN TIMESTAMP minvalue AND maxvalueWHERE employee_id = 106ORDER BY versions_starttime NULLS FIRST;LAST_NAME VERSIONS_STARTTIME VERSIONS_ENDTIME V------------- ---------------------- ---------------------- -Pataballa 22-MAR-09 09.54.57 PMRojashin 22-MAR-09 09.54.57 PM 22-MAR-09 10.07.06 PM UHussaina 22-MAR-09 10.07.06 PM 22-MAR-09 10.14.04 PM UHussaina 22-MAR-09 10.14.04 PM DPataballa 22-MAR-09 10.17.21 PM I
  • 12. Flashback Transaction Query FLASHBACK_TRANSACTION_QUERY• Introduced in Oracle 10g R1 XID• Enterprise Edition only START_SCN• Changes made to data at a START_TIMESTAMP transaction level COMMIT_SCN COMMIT_TIMESTAMP• No need to use LogMiner LOGON_USER• Reconstruct SQL to undo UNDO_CHANGE# changes OPERATION TABLE_NAME• Need FLASHBACK ANY TABLE_OWNER TRANSACTON system privilege ROW_ID to query view UNDO_SQL FLASHBACK_TRANSACTION_ QUERY
  • 13. Flashback Transaction Query #2SELECT operation, start_timestamp, undo_sqlFROM flashback_transaction_queryWHERE table_name = EMPLOYEESAND table_owner = HR;OPERATION START_TIMESTAMPUNDO_SQL------------------------------------------------------UPDATE 22-MAR-09 21:53:21update "HR"."EMPLOYEES" set "FIRST_NAME" = Alexander, "SALARY" = 9000 where ROWID = AAARAIAAFAAAABXAAD;DELETE 22-MAR-09 22:14:04insert into "HR"."EMPLOYEES“ ("EMPLOYEE_ID", "FIRST_NAME", "LAST_NAME“ ,"EMAIL", "PHONE_NUMBER", "HIRE_DATE", "JOB_ID", "SALARY", "COMMISSION_PCT", "MANAGER_ID", "DEPARTMENT_ID") values (106, Valli, Hussaina, VPATABAL, 590.423.4560,TO_DATE(05-FEB-98 00:00:00, DD- MON-YY HH24:MI:SS),IT_PROG,4800,NULL,103,60);INSERT 22-MAR-09 22:17:13delete from "HR"."EMPLOYEES" where ROWID = AAARAIAAFAAAABYAAJ;
  • 14. Flashback Table (Drop)• Introduced in Oracle 10g R1 (EE)• Recover a dropped table (does not use UNDO)DROP TABLE job_history;Table dropped.SHOW RECYCLEBINORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME-------------- ------------------------------ ------------ -------------------JOB_HISTORY BIN$ZcGwtQ/sKCbgQAB/AQBl2g==$0 TABLE 2009-03-22:23:27:54FLASHBACK TABLE job_history TO BEFORE DROP;Flashback complete.• Option to rename tableFLASHBACK TABLE jobs TO BEFORE DROP RENAME TO jobs_march;
  • 15. Flashback Drop #2• Recycle bin automatically cleared when tablespace is under “space pressure”• Options for manually clearing space:PURGE TABLE <name> PURGE RECYCLEBINPURGE INDEX <name> PURGE DBA_RECYCLEBINPURGE TABLESPACE <name> DROP TABLE <name> PURGEPURGE TABLESPACE <name>USER <name>• To disable recyclebin: – 10gR1: _recyclebin parameter – 10gR2+: recyclebin parameter
  • 16. Flashback Table #3• Reinstate table to a previous state using TIMESTAMP or SCN (uses UNDO)• ROW MOVEMENT should be enabled.ALTER TABLE employees ENABLE ROW MOVEMENT;Table altered.FLASHBACK TABLE employees TO TIMESTAMPTO_TIMESTAMP(22-MAR-09 21:50, DD-MON-YY HH24:MI);Flashback complete.
  • 17. Flashback Database• Introduced in Oracle 10g R1 (EE)• Quickly rewind a database to fix any issues• Similar to point-in-time recovery, but much faster• Uses flashback logs, a before image of changed blocks• Flashback logs saved in Flash Recovery Area (FRA)• 10g R2 introduced restore points and the ability to flashback through RESETLOGS
  • 18. Flashback Transaction• Introduced in Oracle 11g R1 (EE)• Use to undo changes made by transaction• Uses UNDO and redo logs (archive logs too)• Requires supplemental logging of primary key ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;• Enterprise Manager or PL/SQL interface – Under “Availability” tab, click “View and Manage Transactions” – DBMS_FLASHBACK.TRANSACTION_BACKOUT procedure
  • 19. Flashback Data Archive• Introduced in Oracle 11g R1 (EE)• Total Recall Option – separate license.• Automatically track and maintain changes to data in an application transparent and secure manner.• Uses AS OF construct in SQL.• Historical data can be kept for any specified duration – not dependent on undo or flashback log data.• RETENTION specified in the data archive.• New background process “fbda” captures historic information in a non-intrusive manner.• New record added to history table only for update & delete statements.
  • 20. Settings for Undo Flashback• Enabling automatic Undo – UNDO_MANAGEMENT = AUTO• Parameters controlling amount of undo retained: – UNDO_RETENTION• Guaranteed retention option available – ALTER TABLESPACE <undots> RETENTION GUARANTEE• Flashback Operations using Undo – FB Query, FB Versions Query, FB Transaction, FB Transaction Query, FB Table
  • 21. Flash Recovery Area (FRA)
  • 22. Flash Recovery Area• Area of disk location where recovery related files are stored• Managed via Oracle Managed Files• Free space automatically managed by Oracle, obsolete files under current retention policies are deleted when space needed.• Can act as a disk cache for backup files before writing to tape• Flashback logs required to use the Flashback database feature are created only in FRA
  • 23. Flash Recovery Area #2• Need to specify the disk quota.• Preferable to be on a different disk where database files are not stored.• Permanent and transient files can be stored – permanent files are copies of redo logs and control file.• FRA can be on ASM disk• Oracle server alerts monitors the reclaimable space in FRA
  • 24. Configuring FRA• DB_RECOVERY_FILE_DEST_SIZE – Specify the maximum space allocated for FRA• DB_RECOVERY_FILE_DEST – Location of the FRA• For RAC databases, all instances must have same values• DB_FLASHBACK_RETENTION_TARGET – Specify in minutes how much flashback log information should be retained – Default 1440.
  • 25. FRA Contents• Permanent Files – Copy of control file – Copy of redo log files• Transient Files – Archive log files – Flashback logs – RMAN control file and spfile autobackup – RMAN image copies & backup setsExample File Name: /u05/flash_recovery_area/11GR11/backupset/2009_03_26/o1_mf_ annnn_TAG20090326T004654_4wp5rntg_.bkp
  • 26. Sizing FRA• Bigger the FRA, more useful it becomes• Recommendation: DB Size + Incr backups + archive logs + flashback logs• Flashback logs generated are approximately similar in size to redo logs generated.• If there is not enough free space in FRA, flashback logs are deleted to make room.
  • 27. Using Database Flashback
  • 28. Configuring Flashback• Enable flashback on the database in mount state. SHUTDOWN IMMEDIATE; STARTUP MOUNT; ALTER DATABASE FLASHBACK ON; ALTER DATABASE OPEN;• Flashback logs will be written to FRA, and oldest logs deleted when FRA becomes full.• Database must be in ARCHIVELOG mode.
  • 29. Flashback a Database• To flashback a database is similar to performing a point-in-time recovery• RESETLOGS required to open database. SHUTDOWN IMMEDIATE; STARTUP MOUNT; FLASHBACK DATABASE TO [BEFORE] [SCN | TIME | SEQUENCE ] = value; ALTER DATABASE OPEN RESETLOGS;• Archive logs may be used to fill-in the gaps
  • 30. Using Restorepoints• Introduced in Oracle 10g R2• Very useful when performing planned maintenance• Option to guarantee flashback CREATE RESTORE POINT before_patch; CREATE RESTORE POINT before_patch GUARANTEE FLASHBACK DATABASE; FLASHBACK DATABASE TO RESTORE POINT before_patch; DROP RESTORE POINT before_patch;
  • 31. Using Flashback for DR Testing• Setup FRA and enable flashback logs in the standby database• Create a restore point to go back to• Disable log transport to standby database from primary• Activate the standby database and open database.• When testing is completed, revert back to the restore point using FLASHBACK DATABASE.• Convert the database to physical standby again• Catch up the standby database to primary database• Enable log transport from primary
  • 32. Standby Redo-apply Delay`• Oracle provides time delay in applying the archivelogs to the standby database to delay the propagation of errors and corruption to standby database.• By having flashback logging on the standby database, you can always flashback the standby database, thus eliminate using time-delay.• You can flashback and open the standby database, get the rows/tables that were messed up and put the standby database back in recovery mode.• This helps to avoid outage to primary database for non-critical data recovery.
  • 33. Using and Maintaining FRA
  • 34. Automated RMAN Backups• When no FORMAT clause is specified for RMAN backups, they go into FRA.• Automatic controlfile and spfile backups may be configured to go to FRA.• Consider keeping image copies in FRA, with incrementally updated backups (and with optional rolling window) RUN { RECOVER COPY OF DATABASE WITH TAG daily_incr UNTIL TIME SYSDATE - 3; BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG daily_incr DATABASE; }
  • 35. RMAN FORMAT Clause• If you perform RMAN disk backups with the FORMAT clause specifying the FRA location, they are not managed by Oracle and not considered for FRA cleanup and FRA space management algorithm.• So, to backup to FRA, do not specify the FORMAT clause, the default location is the FRA for RMAN backups when FRA is configured.RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;
  • 36. Backing up FRA• FRA can be backed up only using RMANRUN { ALLOCATE CHANNEL CH01T TYPE sbt_tape; BACKUP RECOVERY AREA; }• Flashback logs, the current control file, and online redo logs are not backed up.• This statement can only back up to a tape device, disk is not supported.
  • 37. Using LOG_ARCHIVE_DEST_n• If you explicitly specify the FRA location in the LOG_ARCHIVE_DEST_n parameter, the archive logs are not considered in the FRA space management algorithm and they are not backed up when you specify the BACKUP RECOVERY AREA command.• The correct specification islog_archive_dest_n= LOCATION= USE_DB_RECOVERY_FILE_DEST
  • 38. FRA Full Errors• Once the Flash Recovery Area is full, Oracle automatically deletes eligible files to reclaim space in the Flash Recovery Area as needed.• Oracle may delete flashback logs from the earliest SCNs to make room for other files.• Alert log errors:ORA-19809: limit exceeded for recovery filesORA-19804: cannot reclaim <nnnnn> bytes disk space from <mmmmm> limitORA-19815: WARNING: db_recovery_file_dest_size of <size of FRA configured> bytes is 100.00% used, and has 0 remaining bytes available.
  • 39. Resolving Full FRA• Make more space available by adjusting DB_RECOVERY_FILE_DEST_SIZE.• Backup the contents of the Flash Recovery Area to a tertiary device such as tape.• Change backup retention policy. CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;• Change archive log deletion policy. CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO SBT;
  • 40. V$ Views
  • 41. Backups/Logs Using FRA• Find out if backups and archive logs are part of the FRA algorithm – IS_RECOVERY_DEST_FILE column in V$BACKUP_PIECE – IS_RECOVERY_DEST_FILE column in V$ARCHIVED_LOG
  • 42. V$RECOVERY_FILE_DEST• Find out the current location, disk quota, space in use, space reclaimable by deleting files, and total number of files in the Flash Recovery Area.SQL> select * from v$recovery_file_dest;NAMESPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES------------ ------------ ----------------- --------------/u01/app/oracle/flash_recovery_area 15728640000 9448377344 10272768 213
  • 43. V$FLASH_RECOVERY_AREA_USAGE• Find out the percentage of the total disk quota used by different types of files. Determine how much space for each type of file can be reclaimed by deleting files that are obsolete, redundant, or already backed up to tape.SQL> SELECT FILE_TYPE, PERCENT_SPACE_USED USED, PERCENT_SPACE_RECLAIMABLE RECLAIM, NUMBER_OF_FILES FILES FROM V$FLASH_RECOVERY_AREA_USAGE;FILE_TYPE USED RECLAIM FILES-------------------- ---------- ---------- ----------CONTROL FILE 0 0 0REDO LOG 0 0 0ARCHIVED LOG 61.66 51.2 216BACKUP PIECE 19.07 9.7 31IMAGE COPY 4.93 .4 8FLASHBACK LOG 1.24 0 9FOREIGN ARCHIVED LOG 0 0 0
  • 44. V$FLASHBACK_DATABASE_LOG• Estimate how far back you can rollback the database using flashback logs, and estimated size based on retention target.SQL> select * from v$flashback_database_log;OLDEST_FLASHBACK_SCN OLDEST_FL RETENTION_TARGET FLASHBACK_SIZE-------------------- --------- ---------------- --------------ESTIMATED_FLASHBACK_SIZE------------------------ 8257936 25-MAR-09 1440 194478080 4303306752
  • 45. Items Learned in this Session• Flashback Operations – Think of flashback before saying “no” or getting ready to recover• Flash Recovery Area – It’s worth even if you use it just for flashback logs – Do not specify FORMAT clause for RMAN or directory name for archive log destination• Flashback Database – Good for critical patching activities, migrations – Use restorepoints
  • 46. Questions…?
  • 47. Thank You…• Please complete the session evaluation form – Biju Thomas – Are you using Flashback yet? – Session # 330• Further questions, comments… – Stop by Booth # 4364 – WWW.ONENECK.COM

×