Your SlideShare is downloading. ×
0
Using Oracle8 i  and Oracle9 i  Log Miner Tim Gorman ( tim @ sagelogix .com )  Principal SageLogix, Inc. LA Oracle Users G...
Agenda <ul><li>Basic overview of Log Miner </li></ul><ul><ul><li>What is it? </li></ul></ul><ul><ul><li>How to use it? </l...
What is Log Miner <ul><li>Log Miner is a mechanism for examining redo log files ( online  or  archived ) from any Oracle8,...
Uses for Log Miner <ul><li>Debugging or auditing DML or DDL actions performed within a specified time period </li></ul><ul...
Using Log Miner <ul><li>PL/SQL packages supplied with the RDBMS to  query  information from ( online  or  archived ) redo ...
Using Log Miner <ul><li>Creating a Log Miner session </li></ul><ul><ul><li>Redo log files must first be added to a  list <...
Using Log Miner <ul><li>Then, the Log Miner session must be started </li></ul><ul><ul><li>to populate the V$LOGMNR_CONTENT...
Using Log Miner <ul><li>OPTIONS parameter in START_LOGMNR procedure: </li></ul><ul><ul><li>Oracle8 i : </li></ul></ul><ul>...
Using Log Miner <ul><li>Procedure END_LOGMNR </li></ul><ul><ul><li>Finishes a Log Miner session </li></ul></ul><ul><li>Fun...
DBMS_LOGMNR_D <ul><li>BUILD </li></ul><ul><ul><li>New parameter OPTIONS </li></ul></ul><ul><ul><ul><li>STORE_IN_FLAT_FILE ...
Using Log Miner <ul><li>V$LOGMNR_CONTENTS view </li></ul><ul><ul><li>SCN NUMBER(15) system change number </li></ul></ul><u...
Using Log Miner <ul><li>V$LOGMNR_CONTENTS view (cont’d) </li></ul><ul><ul><li>DATA_BLK# NUMBER data block address (block #...
Enhanced data analysis <ul><li>In Oracle9 i , LogMiner has been enhanced to provide comprehensive Log Analysis for (almost...
Enhanced data analysis <ul><li>To support redo logfile-based applications (such as  logical standby databases ), PK values...
Enhanced data analysis <ul><li>Supplement logging (cont’d) </li></ul><ul><ul><li>Table supplemental logging </li></ul></ul...
New V$ views <ul><li>V$LOGMNR_CONTENTS </li></ul><ul><ul><li>Very similar to Oracle8i version </li></ul></ul><ul><li>V$LOG...
Documentation <ul><li>Oracle8i/9i Server Administration  manual </li></ul><ul><ul><li>Chapter on “ Using LogMiner to Analy...
Q&A Slides downloadable from http://www.EvDBT.com/papers.htm
Upcoming SlideShare
Loading in...5
×

www.SageLogix.com

568

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
568
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "www.SageLogix.com"

  1. 1. Using Oracle8 i and Oracle9 i Log Miner Tim Gorman ( tim @ sagelogix .com ) Principal SageLogix, Inc. LA Oracle Users Group
  2. 2. Agenda <ul><li>Basic overview of Log Miner </li></ul><ul><ul><li>What is it? </li></ul></ul><ul><ul><li>How to use it? </li></ul></ul><ul><ul><li>Why use it? </li></ul></ul><ul><li>Oracle9 i New Features </li></ul><ul><ul><li>Enhancements to support Log Miner as a major component of Data Guard’s Logical Standby Database feature </li></ul></ul>
  3. 3. What is Log Miner <ul><li>Log Miner is a mechanism for examining redo log files ( online or archived ) from any Oracle8, Oracle8 i , or Oracle9 i database </li></ul><ul><ul><li>The database which generated the logs does not have to be the database used to examine them </li></ul></ul><ul><ul><li>Oracle server processes perform the I/O on redo log files in a Log Miner session </li></ul></ul><ul><ul><ul><li>Session initiated by identifying the log files to be read </li></ul></ul></ul><ul><ul><ul><li>Data is retrieved on demand by SQL queries within the session on the view V$LOGMNR_CONTENTS </li></ul></ul></ul><ul><li>Easy and safe </li></ul><ul><ul><li>Can examine logs in another database altogether </li></ul></ul><ul><ul><li>Only need to generate snapshots of database data dictionary periodically </li></ul></ul>
  4. 4. Uses for Log Miner <ul><li>Debugging or auditing DML or DDL actions performed within a specified time period </li></ul><ul><li>Recovering dropped tables </li></ul><ul><ul><li>by finding the exact SCN of the DROP command </li></ul></ul><ul><ul><li>to allow recovery of a CLONE database the precise SCN-1, instead of an approximate time of day </li></ul></ul><ul><li>Recovering deleted or updated data </li></ul><ul><ul><li>by finding the relevant REDO_SQL statement(s) and running the associated UNDO_SQL command(s) </li></ul></ul><ul><li>Database Replication </li></ul><ul><ul><li>Component of Oracle9 i Data Guard Logical Standby Database feature </li></ul></ul>
  5. 5. Using Log Miner <ul><li>PL/SQL packages supplied with the RDBMS to query information from ( online or archived ) redo log files </li></ul><ul><li>Oracle data dictionary must have previously been exported </li></ul><ul><ul><li>using the DBMS_LOGMNR_D.BUILD procedure </li></ul></ul><ul><ul><li>contents must be valid from when redo logs were generated </li></ul></ul><ul><ul><ul><li>exporting allows point-in-time snapshots of data dictionary </li></ul></ul></ul><ul><li>Package DBMS_LOGMNR_D supplied with Oracle8 i or Oracle9 i </li></ul><ul><ul><li>Can be installed on lower version databases, such as Oracle8 </li></ul></ul><ul><ul><li>Filename: “%OH%/rdbms/admin/dbmslmd.sql” </li></ul></ul>
  6. 6. Using Log Miner <ul><li>Creating a Log Miner session </li></ul><ul><ul><li>Redo log files must first be added to a list </li></ul></ul><ul><ul><ul><li>DBMS_LOGMNR.ADD_LOGFILE( file-name , options ) </li></ul></ul></ul><ul><ul><ul><ul><li>options include: </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>NEW (clear list and add new file) </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>ADDFILE (add file to existing list) </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>REMOVEFILE (remove file from existing list) </li></ul></ul></ul></ul></ul>
  7. 7. Using Log Miner <ul><li>Then, the Log Miner session must be started </li></ul><ul><ul><li>to populate the V$LOGMNR_CONTENTS view with information from the files in the list </li></ul></ul><ul><ul><li>Procedure DBMS_LOGMNR.START_LOGMNR </li></ul></ul><ul><ul><ul><li>Use parameters start-SCN / stop-SCN or start-time / stop-time to restrict analysis to certain redo records (default: no restriction) </li></ul></ul></ul><ul><ul><ul><li>The redo trail contains only numeric IDs for database objects (not symbolic names ) so data dictionary info is necessary to translate to human-readable form: </li></ul></ul></ul><ul><ul><ul><ul><li>Online data dictionary </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Flat-file text extract of data dictionary </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Redo stream contains data dictionary extracts (Oracle9 i only on both source and mining side) </li></ul></ul></ul></ul>
  8. 8. Using Log Miner <ul><li>OPTIONS parameter in START_LOGMNR procedure: </li></ul><ul><ul><li>Oracle8 i : </li></ul></ul><ul><ul><ul><li>USE_COLMAP </li></ul></ul></ul><ul><ul><ul><li>SKIP_CORRUPTION </li></ul></ul></ul><ul><ul><li>Oracle9 i : </li></ul></ul><ul><ul><ul><li>SKIP_CORRUPTION </li></ul></ul></ul><ul><ul><ul><li>PRETTY_SQL </li></ul></ul></ul><ul><ul><ul><li>DICT_FROM_ONLINE_CATALOG </li></ul></ul></ul><ul><ul><ul><li>COMMITTED_DATA_ONLY </li></ul></ul></ul><ul><ul><ul><li>DDL_DICT_TRACKING </li></ul></ul></ul><ul><ul><ul><li>DICT_FROM_REDO_LOGS </li></ul></ul></ul><ul><ul><ul><li>NO_SQL_DELIMITER </li></ul></ul></ul><ul><ul><ul><li>CONTINUOUS_MINE </li></ul></ul></ul>
  9. 9. Using Log Miner <ul><li>Procedure END_LOGMNR </li></ul><ul><ul><li>Finishes a Log Miner session </li></ul></ul><ul><li>Function MINE_VALUE return VARCHAR2 </li></ul><ul><ul><li>Parameter SQL_REDO_UNDO </li></ul></ul><ul><ul><li>Parameter COLUMN_NAME </li></ul></ul><ul><ul><li>Returns the value of the specified column in the REDO/UNDO SQL </li></ul></ul><ul><ul><li>Returns NULL if column not present or has NULL value </li></ul></ul><ul><li>Function COLUMN_PRESENT return NUMBER </li></ul><ul><ul><li>Parameter SQL_REDO_UNDO </li></ul></ul><ul><ul><li>Parameter COLUMN_NAME </li></ul></ul><ul><ul><li>Returns 1 if column is present, 0 if not present </li></ul></ul>
  10. 10. DBMS_LOGMNR_D <ul><li>BUILD </li></ul><ul><ul><li>New parameter OPTIONS </li></ul></ul><ul><ul><ul><li>STORE_IN_FLAT_FILE </li></ul></ul></ul><ul><ul><ul><li>STORE_IN_REDO_LOGS (Oracle9 i ) </li></ul></ul></ul><ul><ul><li>Progress of BUILD now visible (via DBMS_OUTPUT) when SET SERVEROUTPUT ON enabled in SQL*Plus </li></ul></ul><ul><li>SET_TABLESPACE procedure (Oracle9 i ) </li></ul><ul><ul><li>By default, internal tables used by Log Miner reside in the SYSTEM tablespace </li></ul></ul><ul><ul><li>SET_TABLESPACE changes to the specified tablespace and moves the tables (if already present somewhere else) </li></ul></ul>
  11. 11. Using Log Miner <ul><li>V$LOGMNR_CONTENTS view </li></ul><ul><ul><li>SCN NUMBER(15) system change number </li></ul></ul><ul><ul><li>TIMESTAMP DATE timestamp of redo vector </li></ul></ul><ul><ul><li>THREAD# NUMBER redo log thread number </li></ul></ul><ul><ul><li>LOG_ID NUMBER redo log sequence # </li></ul></ul><ul><ul><li>XIDUSN NUMBER XID (transaction ID) rollback segment # </li></ul></ul><ul><ul><li>XIDSLOT NUMBER XID transaction table slot </li></ul></ul><ul><ul><li>XIDSQN NUMBER XID sequence # of slot </li></ul></ul><ul><ul><li>RBASQN NUMBER RBA (redo byte address) log seq # </li></ul></ul><ul><ul><li>RBABLK NUMBER RBA block within file </li></ul></ul><ul><ul><li>RBABYTE NUMBER RBA byte offset within block </li></ul></ul><ul><ul><li>UBAFIL NUMBER UBA (undo byte address) file # </li></ul></ul><ul><ul><li>UBABLK NUMBER UBA block within file </li></ul></ul><ul><ul><li>UBAREC NUMBER UBA record within block </li></ul></ul><ul><ul><li>UBASQN NUMBER UBA sequence of block </li></ul></ul><ul><ul><li>ABS_FILE# NUMBER absolute file# </li></ul></ul><ul><ul><li>REL_FILE# NUMBER relative (to tablespace) file# </li></ul></ul>
  12. 12. Using Log Miner <ul><li>V$LOGMNR_CONTENTS view (cont’d) </li></ul><ul><ul><li>DATA_BLK# NUMBER data block address (block #) </li></ul></ul><ul><ul><li>DATA_OBJ# NUMBER data object# </li></ul></ul><ul><ul><li>DATA_DOBJ# NUMBER data block data object# </li></ul></ul><ul><ul><li>SEG_OWNER VARCHAR2(30) segment owner </li></ul></ul><ul><ul><li>SEG_NAME VARCHAR2(81) segment name </li></ul></ul><ul><ul><li>SEG_TYPE NUMBER type of segment </li></ul></ul><ul><ul><li>SEG_TYPE_NAME VARCHAR2(32) name of type of segment </li></ul></ul><ul><ul><li>TABLESPACE_NAME VARCHAR2(30) segment’s tablespace </li></ul></ul><ul><ul><li>ROW_ID VARCHAR2(18) row ID </li></ul></ul><ul><ul><li>SESSION# NUMBER session ID </li></ul></ul><ul><ul><li>SERIAL# NUMBER serial# of session </li></ul></ul><ul><ul><li>USER_NAME VARCHAR2(30) Oracle account name </li></ul></ul><ul><ul><li>SESSION_INFO VARCHAR2(4000) additional info </li></ul></ul><ul><ul><li>ROLLBACK NUMBER 0=commit, 1=rollback </li></ul></ul><ul><ul><li>OPERATION VARCHAR2(30) SQL command type </li></ul></ul><ul><ul><li>SQL_REDO VARCHAR2(4000) SQL statement </li></ul></ul><ul><ul><li>SQL_UNDO VARCHAR2(4000) “reverse” SQL stmt </li></ul></ul><ul><ul><li>INFO VARCHAR2(32) informational msg </li></ul></ul>
  13. 13. Enhanced data analysis <ul><li>In Oracle9 i , LogMiner has been enhanced to provide comprehensive Log Analysis for (almost) all types of data: </li></ul><ul><ul><li>Index-organized tables </li></ul></ul><ul><ul><li>Clustered tables </li></ul></ul><ul><ul><li>Chained and migrated rows </li></ul></ul><ul><ul><li>LOBs and LONGs </li></ul></ul><ul><ul><li>direct-path loaded data </li></ul></ul><ul><ul><li>scalar object types </li></ul></ul><ul><ul><li>All DDL commands </li></ul></ul><ul><li>Still missing: </li></ul><ul><ul><li>Collection object types (i.e. VARRAYs and NESTED TABLES) </li></ul></ul>
  14. 14. Enhanced data analysis <ul><li>To support redo logfile-based applications (such as logical standby databases ), PK values and/or before-images may need to be added to the redo stream </li></ul><ul><ul><li>Database supplemental logging </li></ul></ul><ul><ul><ul><li>Minimal </li></ul></ul></ul><ul><ul><ul><ul><li>Allows Log Miner to group REDO logs for individual DML statements </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>ALTER DATABASE ADD SUPPLEMENTAL LOG DATA </li></ul></ul></ul></ul></ul><ul><ul><ul><li>Primary key logging </li></ul></ul></ul><ul><ul><ul><ul><li>Allows identification of rows logically rather than using ROWIDS </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Requirement for using Logical Standby database: </li></ul></ul></ul></ul><ul><ul><ul><ul><li>ALTER DATABASE ADD SUPPLEMENTAL DATA (PRIMARY KEY, UNIQUE KEY) COLUMNS; </li></ul></ul></ul></ul>
  15. 15. Enhanced data analysis <ul><li>Supplement logging (cont’d) </li></ul><ul><ul><li>Table supplemental logging </li></ul></ul><ul><ul><ul><li>Logs column before-image values </li></ul></ul></ul><ul><ul><ul><ul><li>An application might require that the before-image of the entire row be logged </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Not just the columns being changed </li></ul></ul></ul></ul></ul>
  16. 16. New V$ views <ul><li>V$LOGMNR_CONTENTS </li></ul><ul><ul><li>Very similar to Oracle8i version </li></ul></ul><ul><li>V$LOGMNR_DICTIONARY </li></ul><ul><ul><li>New for Oracle9i, shows info about dictionary being used (flat-file or online) </li></ul></ul><ul><li>V$LOGMNR_LOGS </li></ul><ul><ul><li>New for Oracle9i, shows info about logfiles being analyzed </li></ul></ul><ul><li>V$LOGMNR_PARAMETERS </li></ul><ul><ul><li>Shows values for current Log Miner session, showing parameter values passed to START_LOGMNR </li></ul></ul>
  17. 17. Documentation <ul><li>Oracle8i/9i Server Administration manual </li></ul><ul><ul><li>Chapter on “ Using LogMiner to Analyze Online and Archived Redo Logs ” </li></ul></ul><ul><li>Oracle8i/9i Supplied Packages Reference manual </li></ul><ul><ul><li>Chapters on “ DBMS_LOGMNR ” and “ DBMS_LOGMNR_D ” </li></ul></ul><ul><li>Oracle9i Server Administration manual </li></ul><ul><ul><li>Section on “ Database Supplemental Logging ” and “ Table Supplemental Logging ” </li></ul></ul><ul><li>Oracle9i Data Warehousing Guide manual </li></ul><ul><ul><li>Chapter 15 on “ Change Data Capture ” </li></ul></ul><ul><li>Oracle9i Supplied Packages Reference manual </li></ul><ul><ul><li>Chapters on “ DBMS_LOGMNR_CDC_PUBLISH ” and “ DBMS_LOGMNR_CDC_SUBSCRIBE ” </li></ul></ul>
  18. 18. Q&A Slides downloadable from http://www.EvDBT.com/papers.htm
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×