1. 程式人生 > >記一次追溯業務表被刪除的原因

記一次追溯業務表被刪除的原因

運維專案生產環境內兩張業務表丟失,導致應用無法使用,後開發人員通過邏輯備份後將其恢復,但甲方要明確刪除動作,一下介紹通過日誌挖掘來查詢表丟失的原因,此文件省略部分輸出結果,只記錄解決思路。

一、環境資訊:

作業系統版本: AIX 6.1

資料庫版本:oracle  11.2.0.4

資料庫配置:RAC

資料檔案格式:裸裝置

二、處理過程

1.sys使用者登入資料庫,檢查是否存在logminer 的程式包

SQL>desc dbms_logmnr

⚠️如果查詢結果顯示未安裝,則需執行指令碼安裝:SQL>@$ORACLE_HOME/rdbms/admin/dbmslm.sql

2.檢視問題時間段的所產生的歸檔檔案,檢視事故發生點在first_time與next_time時間段內發生的歸檔

SQL>select inst_id,name,to_char(first_time,'yyyy-mm-dd hh24:mi:ss'),to_char(next_time,'yyyy-mm-dd hh24:mi:ss'),sequence# from v$archived_log where first_time>=to_data('2018-01-01','yyyy-mm-dd hh24:mi:ss') and first_time<=('2018-01-02','yyyy-mm-dd hh24:mi:ss') order by 3 desc;

3.由於生產環境使用 tsm 備份至帶庫,需將其恢復:

run {

allocate channel t1 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';

restore archive log sequence between ???? and ????;

release channel t1;

 }

4.將歸檔日誌恢復到預設路徑後,利用logminer進行日誌挖掘

execute dbms_logmnr.add_logfile(logfile_name=>'/步驟三中歸檔的歸檔日誌',option=>dbms_logmnr.new);              --首次加入歸檔日誌

execute dbms_logmnr.start_logmnr(option=>dbms_logmnr.dict_from_online_catalog);  --對加入的歸檔日誌進行日誌挖掘

5.挖掘語句執行結束後,日誌資訊被儲存在v$logmnr_contents檢視中,並對其他使用者不可見,由於刪表動作屬於ddl操作,直接檢查檢視內的ddl資訊的日誌條目:

SQL>select * from v$logmnr_contents where operation='DDL';