DBA手记(学习) - LOGMNR 简单而强大的工具
LOGMNR
首先执行一个ddl(或dml)操作,以记录重做信息:
SYS@ ora11g>conn scott/tiger
Connected.
SCOTT@ ora11g>alter system switch logfile;
System altered.
SCOTT@ ora11g>create table user1 as select * from dba_users;
Table created.
SCOTT@ ora11g>select count(*) from user1;
COUNT(*)
----------
33
然后执行LOGMNR解析工作:
SCOTT@ ora11g>conn / as sysdba
Connected.
SYS@ ora11g>select * from v$log where status = 'CURRENT';
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- ---------- --------- ------------------------------------------------ ------------- ------------------
NEXT_CHANGE# NEXT_TIME
------------ ------------------
1 1 163 52428800 512 1 NO CURRENT 2454437 29-MAY-18
2.8147E+14
SYS@ ora11g>select member from v$logfile where group#=1;
MEMBER
----------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/oracle/newdb/redo01.log
SYS@ ora11g>exec dbms_logmnr.add_logfile('/home/oracle/newdb/redo01.log',dbms_logmnr.new);
PL/SQL procedure successfully completed.
添加文件完成后,可以查看scn和time等信息,进行分析时,也可以指定scn:
alter sessin set nls_date_format="yyyy-dd-mm hh24:mi:ss";
select log_id,low_scn,low_time,next_scn,high_time from v$logmnr_logs;
SYS@ ora11g>exec dbms_logmnr.start_logmnr(options=>dbms_logmnr.dict_from_online_catalog);
PL/SQL procedure successfully completed.
SYS@ ora11g>select count(*) from v$logmnr_contents;
COUNT(*)
----------
133
分析之后就可以查看结果了,redo log记载的信息都能从v$logmnr_contents视图查到,该视图的内容只对当前session有效:
select timestamp,username,session#,sql_redo,operation from v$log_contents;
解析之后,可以通过v$logmnr_contents视图来查询数据库执行所有操作。通过SQL_REDO的这些SQL就可以重演create table的ddl操作。
ddl的后台操作实际上是转换为对字典表呃一系列dml操作。
SYS@ ora11g>select sql_redo from v$logmnr_contents;
SQL_REDO
----------------------------------------------------------------------------------------------------------------------------------------------------------------
set transaction read write;
insert into "SYS"."AUD$"("SESSIONID","ENTRYID","STATEMENT","TIMESTAMP#","USERID","USERHOST","TERMINAL","ACTION#","RETURNCODE","OBJ$CREATOR","OBJ$NAME","AUTH$PRI
VILEGES","AUTH$GRANTEE","NEW$OWNER","NEW$NAME","SES$ACTIONS","SES$TID","LOGOFF$LREAD","LOGOFF$PREAD","LOGOFF$LWRITE","LOGOFF$DEAD","LOGOFF$TIME","COMMENT$TEXT",
"CLIENTID","SPARE1","SPARE2","OBJ$LABEL","SES$LABEL","PRIV$USED","SESSIONCPU","NTIMESTAMP#","PROXY$SID","USER$GUID","INSTANCE#","PROCESS#","XID","AUDITID","SCN"
,"DBID","SQLBIND","SQLTEXT","OBJ$EDITION") values ('720848','2','11',NULL,'SCOTT','wuku','pts/1','49','0',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
,NULL,NULL,NULL,NULL,'oracle',NULL,NULL,NULL,'3',NULL,TO_TIMESTAMP('29-MAY-18 02.39.26.552375 AM'),NULL,NULL,'0','5745',NULL,NULL,NULL,'4090761500',NULL,NULL,NU
LL);
commit;
set transaction read write;
insert into "SYS"."OBJ$"("OBJ#","DATAOBJ#","OWNER#","NAME","NAMESPACE","SUBNAME","TYPE#","CTIME","MTIME","STIME","STATUS","REMOTEOWNER","LINKNAME","FLAGS","OID$
","SPARE1","SPARE2","SPARE3","SPARE4","SPARE5","SPARE6") values ('80448','80448','83','USER1','1',NULL,'2',TO_DATE('29-MAY-18', 'DD-MON-RR'),TO_DATE('29-MAY-18'
, 'DD-MON-RR'),TO_DATE('29-MAY-18', 'DD-MON-RR'),'1',NULL,NULL,'0',NULL,'6','1','83',NULL,NULL,NULL);
set transaction read write;
Unsupported
commit;
insert into "SYS"."CON$"("OWNER#","NAME","CON#","SPARE1","SPARE2","SPARE3","SPARE4","SPARE5","SPARE6") values ('83','SYS_C0014249','14249','0',NULL,NULL,NULL,NU
LL,NULL);
set transaction read write;
Unsupported
commit;
insert into "SYS"."CON$"("OWNER#","NAME","CON#","SPARE1","SPARE2","SPARE3","SPARE4","SPARE5","SPARE6") values ('83','SYS_C0014250','14250','0',NULL,NULL,NULL,NU
LL,NULL);
set transaction read write;
Unsupported
commit;
insert into "SYS"."CON$"("OWNER#","NAME","CON#","SPARE1","SPARE2","SPARE3","SPARE4","SPARE5","SPARE6") values ('83','SYS_C0014251','14251','0',NULL,NULL,NULL,NU
LL,NULL);
set transaction read write;
Unsupported
commit;
insert into "SYS"."CON$"("OWNER#","NAME","CON#","SPARE1","SPARE2","SPARE3","SPARE4","SPARE5","SPARE6") values ('83','SYS_C0014252','14252','0',NULL,NULL,NULL,NU
LL,NULL);
set transaction read write;
Unsupported
commit;
insert into "SYS"."CON$"("OWNER#","NAME","CON#","SPARE1","SPARE2","SPARE3","SPARE4","SPARE5","SPARE6") values ('83','SYS_C0014253','14253','0',NULL,NULL,NULL,NU
LL,NULL);
set transaction read write;
Unsupported
commit;
insert into "SYS"."CON$"("OWNER#","NAME","CON#","SPARE1","SPARE2","SPARE3","SPARE4","SPARE5","SPARE6") values ('83','SYS_C0014254','14254','0',NULL,NULL,NULL,NU
LL,NULL);
set transaction read write;
Unsupported
commit;
insert into "SYS"."CON$"("OWNER#","NAME","CON#","SPARE1","SPARE2","SPARE3","SPARE4","SPARE5","SPARE6") values ('83','SYS_C0014255','14255','0',NULL,NULL,NULL,NU
LL,NULL);
create table user1 as select * from dba_users;
set transaction read write;
查询完成之后,结束日志解析过程:
SYS@ ora11g>exec dbms_logmnr.end_logmnr;
PL/SQL procedure successfully completed.
DBA手记(学习) - LOGMNR 简单而强大的工具的更多相关文章
- 让AI简单且强大:深度学习引擎OneFlow技术实践
本文内容节选自由msup主办的第七届TOP100summit,北京一流科技有限公司首席科学家袁进辉(老师木)分享的<让AI简单且强大:深度学习引擎OneFlow背后的技术实践>实录. 北京 ...
- Spring 简单而强大的事务管理功能
开始之前 关于本教程 本教程将深入讲解 Spring 简单而强大的事务管理功能,包括编程式事务和声明式事务.通过对本教程的学习,您将能够理解 Spring 事务管理的本质,并灵活运用之. 先决条件 本 ...
- (译文)12个简单(但强大)的JavaScript技巧(二)
原文链接: 12 Simple (Yet Powerful) JavaScript Tips 其他链接: (译文)12个简单(但强大)的JavaScript技巧(一) 强大的立即调用函数表达式 (什么 ...
- (译文)12个简单(但强大)的JavaScript技巧(一)
原文连接: 12 Simple (Yet Powerful) JavaScript Tips 我将会介绍和解析12个简单但是强大的JavaScript技巧. 这些技巧所有的JavaScript程序员都 ...
- 简单而强大的bitset
简单而强大的bitset 介绍 有些程序需要处理二进制有序集,标准库提供了bitset 类型,事实上,bitset 是一个二进制容器,容器中每一个元素都是一位二进制码,或为 0,或为 1. 基础 bi ...
- 图解HTTP学习笔记——简单的HTTP协议
简单的HTTP协议 前言 最近在学习Web开发的相关知识,发现<图解HTTP>这本书通俗易懂.所以花时间学习这本书,并记录下学习笔记. 如上图,我们每天都在浏览网页,一般我们都是在浏览器地 ...
- TYAttributedLabel——简单,强大的iOS属性文本控件
本文转载至 http://www.mobile-open.com/2015/86578.html TYAttributedLabel 简单,强大的属性文本的控件(无需了解CoreText),支持图文混 ...
- (java)selenium webdriver学习---实现简单的翻页,将页面内容的标题和标题链接取出
selenium webdriver学习---实现简单的翻页,将页面内容的标题和标题链接取出: 该情况适合能能循环page=1~n,并且每个网页随着循环可以打开的情况, 注意一定是自己拼接的url可以 ...
- IIC驱动学习笔记,简单的TSC2007的IIC驱动编写,测试
IIC驱动学习笔记,简单的TSC2007的IIC驱动编写,测试 目的不是为了编写TSC2007驱动,是为了学习IIC驱动的编写,读一下TSC2007的ADC数据进行练习,, Linux主机驱动和外设驱 ...
随机推荐
- Mac里用终端ssh远程连接Centos服务器
在mac终端下输入 ssh -l root *.*.*.* 就可以远程连接Centos服务器了,端口没变还是:22 如果改变端口用下面方法输入: ssh -p 448(你改变的端口) -l root( ...
- 微信小程序-movable-view
<view class="page-body"> <view class="page-section"> <view class= ...
- (WCF) 利用WCF实现两个Process之间的通讯。
目的: 实现两个独立的Process 之间的通讯. 实现思路: 建立一个WCF Service,然后将其Host到一个Console 程序中,然后在另外一个Console程序中引用WCF的Servic ...
- Android GridView显示SD卡的图片
GridView的XML布局: main.xml: <GridViewxmlns:android="http://schemas.android.com/apk/res/android ...
- JAVA中获取文件的大小和文件的扩展名
一.获取文件扩展名(该段代码来自博客园网站装男人的博客https://www.cnblogs.com/nanrenzhuang/archive/2013/05/19/6315546.html) pub ...
- java编写银行管理 。ATM管理
package Demo; import java.util.Date; import java.util.Scanner; //date是数据库中的一个用法,初始化后输出的是操作时的时间 publi ...
- String,StringBuffer和StringBuilder三者的讲解
对于java的学习者而言,无论是初学者,还是java大师,String对于大家而言,也绝对不会陌生.下面本人就从 自己学习的角度大致分析一下String,StringBuffer和StringBui ...
- how to drop multiple talbes in oracle use a sigle query
Tool:PL/SQL developer Syntax:SELECT 'DROP TABLE ' || table_name || ';' FROM user_tables; 1.then you ...
- August 30th 2017 Week 35th Wednesday
A lion does not concern himself with the opinion of sheep. 狮子可不会在意绵羊是怎么想的. As a sheep, you must run ...
- Nowcoder Girl 初赛 T5
Nowcoder Girl 初赛第五题 来源 Nowcoder Girl 初赛第五题 题面 \(n(1<=n<=10000)\)件武器,每件武器对于属性有加成,一共五种属性.若使用其中的\ ...