dump日誌檔案

tolywang發表於2009-04-09

使用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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章