Use the Oracle Logminer to protect your data and move to the...

47
Session ID: Prepared by: Use the Oracle Logminer to protect your data and move to the Cloud! 439 Konstantin Kerekovski, Raymond James Financial

Transcript of Use the Oracle Logminer to protect your data and move to the...

Page 1: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

SessionID:

Preparedby:

UsetheOracleLogminertoprotectyourdataandmovetotheCloud!

439

KonstantinKerekovski,RaymondJamesFinancial

Page 2: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

BIO

KonstantinRomanovKerekovski

WorkExperience:• AmericanExpress– OracleDBA11g,12c,RAC,GG,DG• RaymondJamesFinancial– OracleDBA11g,12c,Exadata,ODA

ExperiencewithReplicationTechnologies:• Goldengate11g,12c• Dataguard11g,12c• Logminer11g,12c

Page 3: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

WhatistheLogminer?

• Asuiteofpackagesandviews• Atooltoanalyzeyourarchivedlogs

Page 4: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

RecommendedSettings

• MinimumDatabaseSupplementalloggingenabled.

• (Optional)SupplementalloggroupsontablesinvolvedinanyLogminerreplication.

Page 5: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

WhatisSupplementalLogging?

• Extraredologgingotherthanwhatisrequiredtorecoverdatabasechangesviamediarecovery(RMAN).

Examples:• Sessionlevelinformation• Beforeimagesofcolumns

Page 6: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

WhyisSupplementalLoggingimportant?

• LogminercannotreturnvalidSQLstatementswithoutsupplementallogging.• Logminerwillnotbeusableforanyauditingpurposesduetomissingredodata.

Page 7: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

AddingDatabaseMinimumSupplementalLogging

SQL> alter database add supplemental log data;

Database altered.

Page 8: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

AddingDatabaseMinimumSupplementalLogging(cont’d)

Page 9: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

OtherLevelsofDBSupplementalLogging

Page 10: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

DatabaseSupplementalLoggingconsiderations

• In12c,supplementalloggingdoneatCDB$ROOTenablessupplementalloggingonallPDBs.• IncreasesamountofREDOgeneratedbyALLtransactions.

Page 11: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Whyistable-levelSupplementalLoggingneeded?

• Tostorebefore-imagesofkeycolumnsintoredostream.

• ToensureSQLretrievedfromSQL_REDOcolumnhastheproperpredicatesinwhereclause.

• ToavoidusingROW_ID’swhenrerunningSQL_REDOdata.

Page 12: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Addingtable-levelSupplementalLogging

IdentificationKeyLogging

Page 13: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Addingtable-levelSupplementalLogging

CustomLogGroups

Page 14: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

SupplementalLogTestCase

Page 15: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Whathappenswithnotable-levelSupplementalLogging?

Page 16: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Whathappenswithnotable-levelSupplementalLogging?(cont’d)

Page 17: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

NoSupplementalLoggingwhatsoever

Page 18: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

WhathappenswithallcolumnSupplementalLogging?

Page 19: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

WhathappenswithallcolumnSupplementalLogging?(cont’d)

Page 20: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

WhathappenswithPKSupplementalLogging?

Page 21: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

WhathappenswithPKSupplementalLogging?(cont’d)

Page 22: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

WhyPrimaryKey IdentificationKeySupplementalLoggingissafer

Page 23: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

WhyPrimaryKey IdentificationKeySupplementalLoggingissafer(cont’d)

Page 24: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

DatabaseObjectsofinterest

• DBMS_LOGMNR_D

• DBMS_LOGMNR

• V$LOGMNR_CONTENTS

Page 25: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

DBMS_LOGMNR_D

• DatabasePackage• Usedtostoredatadictionaryinflatfilesortheredologs.

Page 26: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

TheDataDictionary

• MapsObjectIDstoObjectNames,aidsinDDLtracking.

• Canbeaccessedin3differentways1. Fromstoredversioninredologs2. Fromstoredversionaflatfile3. Fromthedatabaseitself.

Page 27: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Whyyoushoulduse1ofthe3datadictionaryoptions

Page 28: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

DBMS_LOGMNR

• Startsandendslogminingsessions.

• Specifieswhichredologsaretobeanalyzed.

• SpecifieshowtodisplaySQL_REDOandSQL_UNDOviaOPTIONSargumentinSTART_LOGMNR

Page 29: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

START_LOGMNROptions

• NO_SQL_DELIMITER• NO_ROW_ID_IN_STMT• COMMITTED_DATA_ONLY• CONTINUOUS_MINE

• DDL_DICT_TRACKING• DICT_FROM_ONLINE_CATALOG• DICT_FROM_REDO_LOGS

Page 30: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

COLUMN_PRESENTandMINE_VALUE

Page 31: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

COLUMN_PRESENTandMINE_VALUE(cont’d)

Page 32: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

V$LOGMNR_CONTENTS

• ViewexposingREDOandUNDOminedviaDBMS_LOGMNR• SystemPrivilegeNeeded(12c)

• LOGMINING• SELECT_CATALOG_ROLE

• SystemPrivilegeNeeded(11g)• SELECTANYTRANSACTION• SELECT_CATALOG_ROLE

Page 33: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

WhathappenswhenV$LOGMNR_CONTENTSisqueried?

• RedoisanalyzedaccordingtoSTARTSCN/ENDSCNorSTARTTIME/ENDTIME.• Logfiles aredynamicallyaddedtologminingsessionifCONTINUOUS_MINEwasspecified.• REDOandUNDOdataisreturnedintheformofROWS.• ChangerecordsreturnedinascendingSCNorderunlessotherwisespecifiedinSQLstatement.

Page 34: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Additionalinterestingviews• V$LOGMNR_LOGS- ContainsadditionalinformationonARCHIVELOGS.

• V$LOGMNR_PARAMETERS– Informationoncurrentlogminingsession.

Page 35: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

AlittlemoreonV$LOGMNR_PARAMETERS

Page 36: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

AuditingDatabaseActivity

Page 37: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Databasechangecausesoutage

• Databasesuddenlybecomesunresponsive.

• Databaseserverisunabletocreateanynewprocessesandneedstoberebooted.

• Everyoneispanickingandmanagementisverydispleased.

Page 38: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Whatdoweknow?

1. Aheavilyusedindex(HR.EMP_EMP_ID_PK)wasrecentlyalteredtoPARALLEL99.

2.Thedatabaseisauditingchangestoindexes.

3.DBA_AUDIT_TRAILhasnoauditrecordsforindex!

Page 39: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

DBMS_LOGMNRtotherescue!

Page 40: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

Verifyingoursuspicions

Page 41: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

RecoveringfromLogicalCorruption

Page 42: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

BotchedUpdateScript

SQL> !cat update_salary.sql

set echo on;

update hr.employees set salary = 100000;

where employee_id =100;

commit;

Page 43: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

OutcomeSQL> @update_salary.sql

SQL> update hr.employees set salary = 100000;

107 rows updated.

SQL> where employee_id =100;

SP2-0734: unknown command beginning "where empl..." - rest of

line ignored.

SQL> commit;

Commit complete.

Page 44: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

DBMS_LOGMNRtotherescue!

Page 45: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

April2-6,2017inLasVegas,NVUSA#C17LV

RetrievingtheSQL_UNDO

Page 46: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

References

https://github.com/kerekovskik/COLLABORATE_2017https://github.com/kerekovskik/COLLABORATE_2017/wikihttps://docs.oracle.com/database/121/SUTIL/toc.htmhttps://docs.oracle.com/database/121/ARPLS/d_sql.htm

Page 47: Use the Oracle Logminer to protect your data and move to the …nyoug.org/wp-content/uploads/2017/07/Kerekovski_logminer... · 2017-07-02 · Use the Oracle Logminer to protect your

Q&A