ITPub博客

首页 > Linux操作系统 > Linux操作系统 > dump日志文件

dump日志文件

原创 Linux操作系统 作者:tolywang 时间:2009-04-09 10:48:59 0 删除 编辑

使用ALTER SYSTEM DUMP LOGFILE可以DUMP在线日志文件。也可以使用ALTER SESSION命令去DUMP REDO LOG头的信息。在数据库处于NOMOUNTMOUNT或者OPEN状态的时候都可以使用���面的命令。当操作系统是相同的情况下,可以通过客户端去DUMP另外一个数据库的REDO LOGREDO LOG的信息会被写入一个TRACE文件。

可以用下面的方法去DUMP在线日志:

l         通过DBAData Block Address)去DUMP记录

l         通过RBARedo Block Address)去DUMP记录

l         根据事件点去DUMP记录

l         根据层次和操作码去DUMP记录

l         DUMP文件头信息

l         DUMP整个LOG文件

根据DBA DUMP在线日志记录:

DUMP跟某个/某些数据块相关的REDO LOG记录,DUMP出来的信息只和这些数据块相关,命令如下:

ALTER SYSTEM DUMP LOGFILE 'filename' 

 DBA MIN fileno . blockno 

   DBA MAX fileno . blockno; 

  比如:

        ALTER SYSTEM DUMP LOGFILE

 'u01/oracle/V7323/dbs/arch1_76.dbf' 

        DBA MIN 5 . 31125 

        DBA MAX 5 . 31150; 

这个命令DUMP5号文件的3112531150块相关的记录。

 

根据RBA DUMP在线日志记录

    通过REDO地址的范围DUMP在线日志的记录,语法如下:

ALTER SYSTEM DUMP LOGFILE 'filename' 

   RBA MIN seqno . blockno 

   RBA MAX seqno . blockno; 

比如说:

ALTER SYSTEM DUMP LOGFILE 'u01/oracle/V7323/dbs/arch1_76.dbf' 

   RBA MIN 2050 . 13255 

   RBA MAX 2255 . 15555;

 

根据时间点DUMP在线日志记录

    可以通过时间范围来DUMP在某段时间内产生的REDO 记录,语法如下:

ALTER SYSTEM DUMP LOGFILE 'filename' 

   TIME MIN value 

   TIME MAX value; 

 

比如:

        ALTER SYSTEM DUMP LOGFILE

 'u01/oracle/V7323/dbs/arch1_76.dbf' 

        TIME MIN 299425687 

        TIME MAX 299458800; 

  下面的脚本可以在REDO DUMP TIMEDATE类型之间进行相互转换:

REDO DUMP TIME Date格式:

SET ECHO off 

REM NAME:    TFSTM2RD.SQL 

REM USAGE:"@path/tfstm2rd" 

REM ------------------------------------------------------------------------ 

REM REQUIREMENTS: 

REM    None. 

REM ------------------------------------------------------------------------ 

REM AUTHOR:  

REM    Anonymous      

REM    Copyright 1996, Orqacle Corporation   

REM ------------------------------------------------------------------------ 

REM PURPOSE: 

REM    Converts a standard date into redo dump time format. 

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_HOUR REDO_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 purposes only. It is NOT  

REM    supported by Oracle World Wide Technical Support. 

REM    The script. has been tested and appears to work as intended. 

REM    You should always run new scripts on a test instance initially. 

REM ------------------------------------------------------------------------ 

REM Main text of script. 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 format 9999  

column redo_hour  new_value redo_hour format 9999  

column redo_min   new_value redo_min format 9999  

column redo_sec   new_value redo_sec format 9999  

column redo_time  new_value redo_time   

  

set verify 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;  

 

 

以下是使用该脚本的例子: 

Enter day (DD/MM/YYYY) ? 08/07/1996 

Enter time (HH24:MI:SS) ? 12:05:05 

 

REDO_YEAR REDO_MONTH REDO_DAY REDO_HOUR REDO_MIN REDO_SEC 

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

     1996          7        8        12        5        5 

 

 

 REDO_TIME 

---------- 

 273845105

 

以下脚本是将 REDO DUMP TIME转为日期格式:

 

SET ECHO off 

REM NAME:    TFSRD2TM.SQL 

REM USAGE:"@path/tfsrd2tm" 

REM ------------------------------------------------------------------------ 

REM REQUIREMENTS: 

REM None. 

REM ------------------------------------------------------------------------ 

REM AUTHOR:  

REM    Anonymous      

REM    Copyright 1996, Oracle Corporation      

REM ------------------------------------------------------------------------ 

REM PURPOSE: 

REM    Will convert redo dump time into a readable date. 

REM  

REM ------------------------------------------------------------------------ 

REM EXAMPLE: 

REM    Enter redo time ? 273845105 

REM     

REM    REDO_YEAR REDO_MONTH REDO_DAY REDO_HOUR REDO_MIN REDO_SEC 

REM    --------- ---------- -------- --------- -------- -------- 

REM         1996          7        8        12        5    5 

REM  

REM ------------------------------------------------------------------------ 

REM DISCLAIMER: 

REM    This script. is provided for educational purposes only. It is NOT  

REM    supported by Oracle World Wide Technical Support. 

REM    The script. has been tested and appears to work as intended. 

REM    You should always run new scripts on a test instance initially. 

REM ------------------------------------------------------------------------ 

REM Main text of script. 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 format 9999  

column redo_hour  new_value redo_hour format 9999  

column redo_min   new_value redo_min format 9999  

column redo_sec   new_value redo_sec format 9999  

  

set verify 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;  

 

执行的例子如下:

Enter redo time ? 273845105 

 

REDO_YEAR REDO_MONTH REDO_DAY REDO_HOUR REDO_MIN REDO_SEC 

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

     1996          7        8        12        5        5

.

根据层次(LAYER)和操作代码(OPCODEDUMP记录

    根据LAYEROPCODE可以DUMP某种类型的记录。命令格式如下:

ALTER SYSTEM DUMP LOGFILE 'filename' 

   LAYER value 

   OPCODE value; 

  比如:

        ALTER SYSTEM DUMP LOGFILE

 'u01/oracle/V7323/dbs/arch1_76.dbf' 

        LAYER 11 

        OPCODE 3; 

DUMP文件头的信息

    使用下列命令可以DUMP文件头的信息:

   alter session set events 'immediate trace name redohdr level 10'; 

 

 

DUMP整个RED LOG

  使用下列命令可以导出整个REDO LOG:

 

ALTER SYSTEM DUMP LOGFILE 'filename'; 

 

 比如:

 ALTER SYSTEM DUMP LOGFILE 'u01/oracle/V7323/dbs/arch1_76.dbf';

     ALTER SYSTEM DUMP LOGFILE ‘文件名命令即可以DUMP在线日志文件,也可以DUMP归档日志文件。

对于Oracle7或以前的数据库,Oracle可以把归档日志直接写入磁带。Oracle也支持从磁盘或者磁带上读取归档日志,如果从磁盘上读取归档日志,文件名的格式是:

D:MINIDISK:DATASET

DataSet是文件名,比如:

ALTER SYSTEM DUMP LOGFILE

 'D:GOLDDBA.230.230.READPASS.MULTPASS:L123.ORA';

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-586828/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    13275272