oracle dump redo log file 说明 -凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 2090508
  • 博文数量: 195
  • 博客积分: 4378
  • 博客等级: 上校
  • 技术积分: 4046
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-09 11:37
个人简介

白天和黑夜只交替没交换无法想像对方的世界

文章分类

全部博文(195)

文章存档

2014年(3)

2013年(20)

2012年(18)

2011年(107)

2010年(17)

2009年(5)

2008年(20)

2007年(5)

相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: oracle

2013-06-19 16:07:12

 

一. dump redo 说明

            关于dump redo log 的示例,mos 上的文档:[id 1031381.6] 有详细说明。dump 有两种方式:

            (1)使用'alter session' 命令dumpredo header。

            (2)使用'alter system dump logfile' 命令dump logfile contents。

 

            可以在mount,nomout和open状态下使用如上命令,并且使用以上命令需要'alter system' 的权限。 可以使用该命令dump onlie redo log 或者归档文件。 当操作系统系统相同的情况下,还可以dump其他db的log 文件。

 

有如下dump 方法:

            1.to dump records based in dba (data block address)

            2.to dump records based on rba (redo block address)

            3.to dump records based on scn

            4.to dump records based on time

            5.to dump records based on layer and opcode

            6.dump the file header information

            7.dump an entire log file:

 

 

二. 具体使用示例

2.1  to dump records based on dba  (data block address)

关于dba的说明,参考:

           

           

 

            根据dba进行dump,主要是根据file和block 号来进行dump。 这个的block 是一个范围值。

 

11g命令格式如下:

alter system dump logfile 'filename'  dba min fileno . blockno    dba max fileno . blockno;

 

如果是oracle 10g,需要省略'.',即格式如下:

alter system dump logfile 'filename'  dba min fileno  blockno    dba max fileno  blockno;

 

否则会报:  ora-01963: must specify a block number 错误。

 

 

如:

sys@anqing1(rac1)> select * fromv$version where rownum=1;   

banner

----------------------------------------------------------------

oracle database 10g enterprise editionrelease 10.2.0.4.0 - prod

 

sql>select distinct dbms_rowid.rowid_relative_fno(rowid) rel_fno,

dbms_rowid.rowid_block_number(rowid)blockno from ta;

 

  rel_fno    blockno

---------- ----------

        1     294608

        1     294609

        1     294612

        1     294614

        1     294621

        1     294635

        1     294643

        1     294654

        1     294656

        1     294657

        6      10385

 

  rel_fno    blockno

---------- ----------

        6      10393

        6      10410

         6     10411

        6      10415

        6      10416

        6      10458

        6      10461

        6      10464

        6      10465

        6      10468

        6      10472

 

确定log file 位置:

sys@anqing1(rac1)> selecta.group#,a.status,b.member from v$log a,v$logfile b where a.group#=b.group#;

 

   group# status           member

---------- --------------------------------------------------------------------

        3 inactive         data/anqing/onlinelog/redo03.log

        2 inactive         data/anqing/onlinelog/redo02.log

        1 current          data/anqing/onlinelog/group_1.277.751552735

        1 current          fra/anqing/onlinelog/group_1.426.751552739

        4 current          data/anqing/onlinelog/group_4.282.751560131

        5 inactive         data/anqing/onlinelog/group_5.283.751560139

 

6 rows selected.

 

sys@anqing1(rac1)> alter system dump logfile' data/anqing/onlinelog/redo02.log'  dbamin 6  10458    dba max 6 10472;

system altered.

 

sys@anqing1(rac1)> oradebug setmypid

statement processed.

sys@anqing1(rac1)> oradebug tracefile_name

/u01/app/oracle/admin/anqing/udump/anqing1_ora_30373.trc

sys@anqing1(rac1)>

 

[oracle@rac1 ~]$cat /u01/app/oracle/admin/anqing/udump/anqing1_ora_30373.trc

/u01/app/oracle/admin/anqing/udump/anqing1_ora_30373.trc

oracle database 10g enterprise editionrelease 10.2.0.4.0 - production

with the partitioning, real applicationclusters, olap, data mining

and real application testing options

oracle_home =/u01/app/oracle/product/10.2.0/db_1

system name:    linux

node name:      rac1

release:        2.6.18-194.el5

version:        #1 smp tue mar 16 21:52:43 edt 2010

machine:        i686

instance name: anqing1

redo thread mounted by this instance: 1

oracle process number: 28

unix process pid: 30373, image: oracle@rac1(tns v1-v3)

 

*** 2011-08-08 22:10:37.053

*** action name:() 2011-08-08 22:10:37.052

*** module name:(sqlplus@rac1 (tns v1-v3))2011-08-08 22:10:37.052

*** service name:(sys$users) 2011-08-0822:10:37.052

*** session id:(127.27077) 2011-08-0822:10:37.052

 

dump of redo from file' data/anqing/onlinelog/redo02.log'

 opcodes *.*

 dbas: (file # 6, block # 10458) thru (file #6, block # 10472)

 rbas: 0x000000.00000000.0000 thru0xffffffff.ffffffff.ffff

 scns: scn: 0x0000.00000000 thru scn:0xffff.ffffffff

 times: creation thru eternity

 fileheader:

       compatibility vsn = 169870336=0xa200400

       db id=715014091=0x2a9e3fcb, db name='anqing'

       activation id=682502900=0x28ae2af4

       control seq=4261=0x10a5, file size=102400=0x19000

       file number=2, blksiz=512, file type=2 log

 descrip:"thread0001, seq# 0000000119, scn 0x0000006ab1bc-0x0000006e0c84"

 thread: 1 nab: 0x18ffd seq: 0x00000077 hws:0x2 eot: 0 dis: 0

 resetlogs count: 0x2ccbc8df scn:0x0000.000704fa (460026)

 resetlogs terminal rcv count: 0x0 scn:0x0000.00000000

 prevresetlogs count: 0x2ebbfe8f scn: 0x0000.0006ce7b (446075)

 prevresetlogs terminal rcv count: 0x0 scn: 0x0000.00000000

 low scn: 0x0000.006ab1bc (6992316) 07/30/2011 05:39:17

 nextscn: 0x0000.006e0c84 (7212164) 08/03/2011 14:14:34

 enabled scn: 0x0000.000704fa (460026)05/19/2011 12:38:55

 thread closed scn: 0x0000.006ab1bc (6992316)07/30/2011 05:39:17

 diskcksum: 0xd530 calc cksum: 0xd530

 terminal recovery stop scn: 0x0000.00000000

 terminal recovery  01/01/1988 00:00:00

 mostrecent redo scn: 0x0000.00000000

 largest lwn: 1874 blocks

 end-of-redo stream : no

 unprotected mode

 miscellaneous flags: 0x0

 thread internal enable indicator: thr: 0, seq:0 scn: 0x0000.00000000

 

redo record - thread:1 rba:0x000077.00000cd6.017c len: 0x0048 vld: 0x01

scn: 0x0000.006ac8a9 subscn:  1 07/30/2011 08:28:08

change #1 media recovery markerscn:0x0000.00000000 seq:  0 op:18.3

reuse redo entry

range reuse: tsn=1 base=8542185 nblks=8

 

redo record - thread:1 rba:0x000077.00006e99.0078 len: 0x0044 vld: 0x01

scn: 0x0000.006b7ae1 subscn:  1 07/31/2011 06:18:10

change #1 media recovery markerscn:0x0000.00000000 seq:  0 op:17.4

datafile resize marker - file: 2 old size:153600 new size: 156160

 

redo record - thread:1 rba:0x000077.00007884.017c len: 0x0048 vld: 0x01

scn: 0x0000.006b8d16 subscn:  1 07/31/2011 08:33:09

change #1 media recovery markerscn:0x0000.00000000 seq:  0 op:18.3

reuse redo entry

range reuse: tsn=1 base=8542217 nblks=1024

*** 2011-08-08 22:10:54.783

end of redo dump

----- redo read statistics for thread 1-----

read rate (async): 51197kb in 17.78s =>2.81 mb/sec

total physical reads: 51197kb

longest record: 8kb, moves: 0/85186 (0%)

change moves: 30223/143291 (21%), moved:5mb

longest lwn: 937kb, moves: 6/66426 (0%),moved: 0mb

last redo scn: 0x0000.006e087b (7211131)

----------------------------------------------

[oracle@rac1 ~]$

 

 

2.2. to dumprecords based on rba (redo block address)

            在第一节里是根据日志的block number进行dump的,也可以根据日志的sequence#进行dump。

 

格式如下:

alter system dump logfile 'filename' rba min seqno .blockno rba max seqno . blockno;

 

sys@anqing1(rac1)> alter system dump logfile' data/anqing/onlinelog/redo02.log'  rbamin 121 10458  rba max 125 10472;

system altered.

 

其他信息的查看参考第一节。

 

2.3. to dumprecords based on scn

            可以直接根据scn 的值来dump redo log。

 

格式如下:

alter system dump logfile 'filename' scn min minscn scnmax maxscn;

 

sys@anqing1(rac1)> select current_scn from v$database;

current_scn

-----------

    7479813

 

sys@anqing1(rac1)> alter system dump logfile' data/anqing/onlinelog/redo02.log' scn min 7479801 scn max 7479813;

system altered.

 

也可以使用该命令来检查dumpfile,如:

sql> alter system dump logfile 'filename' scn min 1scn max 1;

如果以上语句成功执行,则archivelog 没有问题。

 

2.4. to dumprecords based on time.

            根据时间来dump。

 

格式如下:

alter system dump logfile 'filename' time min value timemax value;

 

如:

alter system dump logfile ' data/anqing/onlinelog/redo02.log'         time min 299425687 timemax 299458800;

 

            注意这里的时间是用redo dump time。 关于redo time 和date 的转换,网上有个脚本。 据说这个脚本出自metalink,但是我在mos 上搜了一下,没有看到这个脚本的内容。

 

脚本1: date to redodump time

/* formatted on2011/8/8 23:00:53 (qp5 v5.163.1008.3004) */

set echo off

rem name:   tfstm2rd.sql

remusage:"@path/tfstm2rd"

rem------------------------------------------------------------------------

rem requirements:

rem   none.

rem------------------------------------------------------------------------

rem author:

rem   anonymous

rem   凯发app官方网站 copyright 1996, orqacle corporation

rem------------------------------------------------------------------------

rem purpose:

rem   converts a standard date into redo dump timeformat.

rem------------------------------------------------------------------------

rem example:

rem   enter day (dd/mm/yyyy) ?08/07/1996

rem   enter time (hh24:mi:ss) ? 12:05:05

rem

rem   redo_year redo_month redo_day redo_hourredo_min redo_sec

rem   --------- ---------- -------- ----------------- --------

rem        1996       7      8       12       5      5

rem

rem   edo_time

rem   ----------

rem    273845105

rem

rem------------------------------------------------------------------------

rem disclaimer:

rem   this script. is provided for educational purposesonly. it is not

rem   supported by oracle world wide technicalsupport.

rem   the script. has been tested and appears towork as intended.

rem   you should always run new scripts on a testinstance initially.

rem------------------------------------------------------------------------

rem main text ofscript. follows:

 

undefine redo_day

undefine redo_hhmiss

 

accept redo_day prompt "enter day (dd/mm/yyyy) ? "

accept redo_hhmiss prompt "enter time (hh24:mi:ss) ? "

 

column redo_year new_value redo_year format 9999

column redo_month new_value redo_month format 9999

column redo_day  new_value redo_day format9999

column redo_hour new_value redo_hour format 9999

column redo_min  new_value redo_min format9999

column redo_sec  new_value redo_sec format9999

column redo_time new_value redo_time

 

setverify off

 

select to_number (

          to_char (

             to_date ('&redo_day&redo_hhmiss', 'dd/mm/yyyy hh24:mi:ss'),

             'yyyy'))

          redo_year,

       to_number (

          to_char (

             to_date ('&redo_day&redo_hhmiss', 'dd/mm/yyyy hh24:mi:ss'),

             'mm'))

          redo_month,

       to_number (

          to_char (

             to_date ('&redo_day&redo_hhmiss', 'dd/mm/yyyy hh24:mi:ss'),

             'dd'))

          redo_day,

       to_number (

          to_char (

             to_date ('&redo_day&redo_hhmiss', 'dd/mm/yyyy hh24:mi:ss'),

             'hh24'))

          redo_hour,

       to_number (

          to_char (

             to_date ('&redo_day&redo_hhmiss', 'dd/mm/yyyy hh24:mi:ss'),

             'mi'))

          redo_min,

       to_number (

          to_char (

             to_date ('&redo_day&redo_hhmiss', 'dd/mm/yyyy hh24:mi:ss'),

             'ss'))

          redo_sec

  from dual;

 

select ( ( ( ( ( (&redo_year - 1988)) * 12 (&redo_month - 1)) * 31

            (&redo_day - 1))

          * 24

          (&redo_hour))

        * 60

        (&redo_min))

       * 60

       (&redo_sec)

          redo_time

  from dual;

 

脚本2: redo dump time todate

/* formatted on2011/8/8 23:02:31 (qp5 v5.163.1008.3004) */

set echo off

rem name:   tfsrd2tm.sql

remusage:"@path/tfsrd2tm"

rem------------------------------------------------------------------------

rem requirements:

rem none.

rem------------------------------------------------------------------------

rem author:

rem   anonymous

rem   凯发app官方网站 copyright 1996, oracle corporation

rem------------------------------------------------------------------------

rem purpose:

rem   will convert redo dump time into a readabledate.

rem

rem------------------------------------------------------------------------

rem example:

rem   enter redo time ? 273845105

rem

rem   redo_year redo_month redo_day redo_hourredo_min redo_sec

rem   --------- ---------- -------- ----------------- --------

rem        1996         7      8       12       5  5

rem

rem------------------------------------------------------------------------

rem disclaimer:

rem   this script. is provided for educationalpurposes only. it is not

rem   supported by oracle world wide technicalsupport.

rem   the script. has been tested and appears towork as intended.

rem   you should always run new scripts on a testinstance initially.

rem------------------------------------------------------------------------

rem main text ofscript. follows:

 

undefine redo_time

 

accept redo_time prompt "enter redo time ? "

 

column redo_year new_value redo_year format 9999

column redo_month new_value redo_month format 9999

column redo_day  new_value redo_day format9999

column redo_hour new_value redo_hour format 9999

column redo_min  new_value redo_min format9999

column redo_sec  new_value redo_sec format9999

 

setverify off

 

select trunc (

          trunc (trunc (trunc (trunc (&redo_time / 60) / 60) / 24) / 31) / 12)

       1988

          redo_year,

       mod (trunc (trunc (trunc (trunc (&redo_time / 60) / 60) / 24) / 31),

            12)

       1

          redo_month,

       mod (trunc (trunc (trunc (&redo_time / 60) / 60) / 24), 31) 1

          redo_day,

       mod (trunc (trunc (&redo_time / 60) / 60), 24) redo_hour,

       mod (trunc (&redo_time / 60), 60) redo_min,

       mod (&redo_time, 60) redo_sec

  from dual;

 

 

2.5. to dumprecords based on layer and opcode.

            layer and opcode are used to dump alllog records for a particular type of redo record, such as all dropped row pieces.

格式如下:

alter system dump logfile 'filename' layer value opcodevalue;

 

示例: 

            sql>altersystem dump logfile ' data/anqing/onlinelog/redo02.log'         layer 11 opcode 3;

 

 

2.6. dump the file header information:

如果是dump onlineredo log 的header 信息,命令如下:

   sql>altersession set events 'immediate trace name redohdr level 10';

 

如果是dump 归档文件的header 信息,命令如下:

   sql>altersystem dump logfile 'filename' rba min 1 1 rba max 1 1;

 

2.7. dump anentire log file:

dump 整个log 文件,命令如下:

sql>alter system dump logfile 'filename';

 

示例:

sql>alter system dump logfile ' data/anqing/onlinelog/redo02.log';

 

 

 

 

-------------------------------------------------------------------------------------------------------

blog: http://blog.csdn.net/tianlesoftware

weibo:

email: dvd.dba@gmail.com

dba1 群:62697716(满);   dba2 群:62697977(满)  dba3 群:62697850(满)  

dba 超级群:63306533(满);  dba4 群: 83829929(满) dba5群: 142216823(满) 

dba6 群:158654907(满)  聊天 群:40132017(满)   聊天2群:69087192(满)

--加群需要在备注说明oracle表空间和数据文件的关系,否则拒绝申请

作者:tianlesoftware 发表于2011-8-8 23:12:14
阅读:282 评论:0


link url:
阅读(9518) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图