Discussion on application of Logminer method _oracle

Source: Internet
Author: User
Tags sqlplus
Logminer is a tool that every DBA should be familiar with, when one day you need to do incomplete recovery due to the user's misoperation, because you are not sure which time to do this operation, so this is very difficult to restore your recovery, the lost data can not be fully restored back. And Logminer can help you determine the exact timing of this error operation.

My test environment is Aix4.3.3 's operating system, Oracle9.2.0.3 's test library.

A few explanations of logminer
1. Logminer can help you determine the specific time and SCN number of various DML,DDL operations that are issued at a certain time, depending on the archive log file and the online log file.
2, it can only be used in oracle8i and later versions, but it could analyze the Oracle8 log.
3, oracle8i can only be used to analyze DML operations, to Oracle9i to analyze DDL operations.
4. Logminer does not support index organization tables, Long, LOB, and collection types.
5, MTS Environment also can not use Logminer.

Second, the Operation steps
1, set up for the Logminer analysis of the data files stored location
This is the process of setting the Utl_file_dir parameter, my example:
A, add the following line to the Initctc.ora file
b, the database to be restarted
Sql>conn/as SYSDBA
Sql>shutdown Immediate

2, the generation of data dictionary files, through the Dbms_logmnr_d.build () to complete.
2 Dbms_logmnr_d.build (
3 Dictionary_filename => Logminer_dict.dat,
4 dictionary_location =>/u01/arch
6 end;

Dictionary_location refers to the location where the Logminer data dictionary file is stored, and it must match the Utl_file_dir settings.
The dictionary_filename refers to the name of the dictionary file placed in the location, and the name can be arbitrarily taken.

3, the establishment of a log analysis table
A, create log Analysis table database must be in mount or Nomount state, start database to mount state.
Sql>conn/as SYSDBA
Sql>shutdown Immediate
Sql>starup Mount

b, the establishment of the Log Analysis table, using Dbms_logmnr.add_logfile ()
2 Dbms_logmnr.add_logfile (
3 Options => Dbms_logmnr.new,
4 LogFileName =>/u01/arch/arc_ctc_0503.arc
6 end;
The options have three values, dbms_logmnr.new is used to build a log Analysis table, Dbms_logmnr.addfile is used to add log files for analysis; dbms_ Logmnr.removefile is used to remove log files for profiling.

4, add the log file for analysis.
2 Dbms_logmnr.add_logfile (
3 Options => Dbms_logmnr.addfile,
4 LogFileName =>/u01/arch/arc_ctc_0504.arc
6 end;

Use to remove this file from the Log Analysis table so that it is not parsed.
2 Dbms_logmnr.add_logfile (
3 Options => Dbms_logmnr.removefile,
4 LogFileName =>/u01/arch/arc_ctc_0503.arc
6 end;

5, start Logminer for analysis.
3 Dictfilename =>/u01/arch/logminer_dict.dat,
4 starttime => to_date (20030501 12:15:00,yyyymmdd hh24:mi:ss),
5 Endtime => to_date (20030501 15:40:30,yyyymmdd hh24:mi:ss)
7 End;

This is to analyze the period from 12:15 to 15:40 on May 1, 2003, and put the results in the data dictionary for querying. There are also two parameter STARTSCN (start SCN number) and ENDSCN (terminating SCN) number.

6, view the results of the log analysis, through the query v$logmnr_contents can query to
A, view DML operations, example:
SELECT operation,
From V$logmnr_contents
WHERE seg_name = Qiuyb;

OPERATION Sql_redo Sql_undo
----------    --------------------------  --------------------------
INSERT inser into Qiuyb.qiuyb ... delete from Qiuyb.qiuyb ...

Where operation refers to the operation, Sql_redo refers to the actual operation, Sql_undo refers to the reverse operation for cancellation.

B, view DDL operations, Example:
SELECT Timstamp,
From V$logmnr_contents
WHERE Upper (Sql_redo) like%truncate%;

7, the end of Logminer analysis.
3 END;

Data dictionary related to Logminer.
1, v$loglist it to display some information about the history log file
2, v$logmnr_dictionary because LOGMNR can have more than one dictionary file, this view is used to display this information.
3, v$logmnr_parameters It is used to display LOGMNR parameters
4, V$logmnr_logs It is used to display the log list information for analysis.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.