dbms_logmnr 線上挖歸檔 恢復資料
需求確認:
A.刪除資料的表:USERNAME.TABLE_NAME
B.執行刪除操作的使用者:USERNAME
C.執行操作的時間範圍:
4月1日10:11左右
操作步驟:
1.查詢指定時間點上的歸檔
select thread#,SEQUENCE#,FIRST_TIME, NEXT_TIME from v$archived_log where to_char(first_time,'yyyy-mm-dd hh24:mi:ss')>'2011-04-01 10:00:00' and to_char(first_time,'yyyy-mm-dd hh24:mi:ss')
1 41242 2011-04-01 10:07:16 2011-04-01 10:08:42
1 41243 2011-04-01 10:08:42 2011-04-01 10:11:24
1 41244 2011-04-01 10:11:24 2011-04-01 10:14:21
1 41245 2011-04-01 10:14:21 2011-04-01 10:21:33
1 41246 2011-04-01 10:21:33 2011-04-01 10:35:45
2 58741 2011-04-01 10:04:55 2011-04-01 10:11:24
2 58742 2011-04-01 10:11:24 2011-04-01 10:24:36
2 58743 2011-04-01 10:24:36 2011-04-01 10:30:48
2.歸檔恢復,分別在兩個例項上進行
run{
allocate channel t1 type sbt;
restore archivelog from sequence 28692 until sequence 28693 thread=1;
release channel t1;
}
run{
allocate channel t1 type sbt;
restore archivelog from sequence 79531 until sequence 79537 thread=2;
release channel t1;
}
3.複製恢復出來的歸檔
考慮到歸檔定期執行,建議將恢復出來的歸檔複製到其它檔案系統下
4.logmnr操作
execute dbms_logmnr.add_logfile(LOGFILENAME=>'/tmp/1_41242_707251512.arc',OPTIONS=>dbms_logmnr.new);
execute dbms_logmnr.add_logfile(LOGFILENAME=>'/tmp/1_41243_707251512.arc',OPTIONS=>dbms_logmnr.addfile);
.
.
.
DBMS_LOGMNR.START_LOGMNR(OPTIONS=>dbms_logmnr.dict_from_online_catalog);
為方便後面的查詢,建議按查詢結果生成表:
create table logmnr
as select a.seg_owner,a.seg_name,a.operation,a.TIMESTAMP,a.sql_redo,a.sql_undo
from v$logmnr_contents a where a.SEG_OWNER='XXX' and a.SEG_NAME='XXX' and a.OPERATION='DELETE';
create table logmnr
as select *
from v$logmnr_contents a where a.SEG_OWNER='XXX' and a.SEG_NAME='XXX' and a.OPERATION='DELETE';
建表方法二:
create table xxz_logmnr nologging as select * from v$logmnr_contents where 1=2;
create table xxz_logmnr nologging TABLESPACE XXX as select * from v$logmnr_contents where 1=2;
insert /*+ append */ into xxz_logmnr select * from v$logmnr_contents;
做這一步之前注意將nls_date_format改成'yyyy-mm-dd hh24:mi:ss',不然中文亂碼,時間會變成問號。
查詢語句:
set lines 200
col seg_owner format a20
col seg_name format a30
set pages 400
select operation,count(operation),seg_owner,seg_name from wudd_logmnr group by seg_owner,seg_name,operation order by count(operation);
Select SQL_REDO, SQL_UNDO from wudd_logmnr where seg_owner=’XXX’;
5.生成臨時表
利用logmnr表中sql_undo中的記錄,生成臨時表,並交應用確認是否為刪除記錄。
create table XXX as select * from
USERNAME.TABLE_NAME where 1=2; =>只要表結構。
執行SQL_UNDO到相應的表
6.結束logmnr
SQL> execute dbms_logmnr.end_logmnr;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22531473/viewspace-748394/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- pt-archiver工具歸檔和恢復資料一例Hive
- 對歸檔模式下CLEAR 未歸檔日誌後恢復資料庫的一點看法模式資料庫
- 從備份片中恢復某個指定得歸檔或者資料檔案
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- 【伺服器資料恢復】掉線硬碟重新上線同步資料被中斷後資料丟失的資料恢復伺服器資料恢復硬碟
- 【伺服器資料恢復】raid5離線硬碟重新上線同步資料失敗的資料恢復案例伺服器資料恢復AI硬碟
- DG歸檔日誌缺失恢復
- 【伺服器資料恢復】raid5強制上線離線硬碟失敗的資料恢復案例伺服器資料恢復AI硬碟
- 【伺服器資料恢復】RAID5崩潰後強制上線導致檔案丟失的資料恢復案例伺服器資料恢復AI
- 磁碟離線資料恢復資料恢復
- 歸檔路徑更改後,如何對資料庫進行恢復(轉)資料庫
- 【伺服器資料恢復】離線硬碟強制上線導致RAID5崩潰的資料恢復伺服器資料恢復硬碟AI
- StorNext伺服器資料恢復案例;硬碟掉線資料恢復伺服器資料恢復硬碟
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- 資料恢復新姿勢——通過ibd和frm檔案恢復資料資料恢復
- 【伺服器資料恢復】StorNext檔案系統資料恢復案例伺服器資料恢復
- DM7使用dmrestore工具利用不同資料庫的歸檔恢復資料庫REST資料庫
- 【資料庫資料恢復】sql server資料庫連線失效的資料恢復案例資料庫資料恢復SQLServer
- 【資料庫資料恢復】Oracle資料庫ASM磁碟組掉線如何恢復資料?資料庫資料恢復OracleASM
- DM7使用DMRAMN對多次故障恢復後使用不同資料庫的歸檔進行恢復資料庫
- 【伺服器資料恢復】ZFS檔案系統下RAIDZ多塊硬碟離線的資料恢復案例伺服器資料恢復AI硬碟
- 【儲存資料恢復】WAFL檔案系統下raid資料恢復案例資料恢復AI
- 【資料庫資料恢復】ASM磁碟組掉線的Oracle資料庫資料恢復案例資料庫資料恢復ASMOracle
- 【BBED】丟失歸檔檔案情況下的恢復
- 資料恢復:AMDU資料抽取恢復資料恢復
- oracle dg 歸檔日誌恢復情況Oracle
- 案例講解伺服器硬碟離線資料恢復方法-資料恢復伺服器硬碟資料恢復
- 【資料庫資料恢復】Sql Server資料庫檔案丟失的資料恢復過程資料庫資料恢復SQLServer
- 【伺服器資料恢復】Raid5熱備盤上線同步時另一塊硬碟離線的資料恢復案例伺服器資料恢復AI硬碟
- 【伺服器資料恢復】RAID5崩潰後強制上線導致資料丟失的資料恢復案例伺服器資料恢復AI
- 【伺服器資料恢復】RAID5崩潰後強制上線導致故障的資料恢復案例伺服器資料恢復AI
- Vsan資料恢復—Vsan資料恢復案例資料恢復
- 【Vsan資料恢復】Vsan資料恢復案例資料恢復
- MSSQL資料庫資料恢復案例:ndf檔案大小變為0KB恢復資料SQL資料庫資料恢復
- 【北亞資料恢復】MongoDB資料遷移檔案丟失的MongoDB資料恢復案例資料恢復MongoDB
- 【資料庫資料恢復】mdb_catalog.wt檔案丟失的MongoDB資料恢復案例資料庫資料恢復MongoDB
- 【資料庫資料恢復】EXT3檔案系統下MYSQL資料庫恢復案例資料庫資料恢復MySql
- 【伺服器資料恢復】xfs檔案系統資料丟失的資料恢復案例伺服器資料恢復
- 資料庫資料恢復-SQL SERVER資料庫檔案大小變為“0”的資料恢復方案資料庫資料恢復SQLServer