亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

動手為王——利用logminer挖掘日志恢復誤操作

發布時間:2020-08-13 07:26:22 來源:ITPUB博客 閱讀:234 作者:kunlunzhiying 欄目:關系型數據庫


挖掘日志恢復誤操作

1 介紹:

LogMinerOracle數據庫提供的一個工具,它用于分析重做日志和歸檔日志所記載的事務操作。

Logmineroracle8i開始提供的用于分析重做日志信息的工具,它包括DBMS_LOGMNRDBMS_LOGMNR_D兩個package。它既能分析redo log file,也能分析歸檔后的archive log file。在分析日志的過程中需要使用數據字典,一般先生成數據字典文件后使用,10g版本還可以使用在線數據字典。

Logminer也可以分析其它數據庫的重做日志文件,但是必須使用重做日志所在數據庫的數據字典,否則會出現無法識別的亂碼。另外被分析數據庫的操作系統平臺最好和當前Logminer所在數據庫的運行平臺一樣,且block size相同。

 

LogMiner的功能

1)確定數據庫的邏輯損壞時間

通過LogMiner可以準確定位該誤操作的執行時間和SCN值,然后通過基于時間恢復或者基于SCN恢復可以完全恢復該表數據。

 SQL> select scn_to_timestamp(2599788) from dual;

scn_to_timestamp(2599788)

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

2016-05-01 06:06:01

 

SQL>select timestamp_to_scn(to_timestamp('2016-5-1 6:06:06','yyyy-mm-dd hh34:mi:ss')) FROM dual;

TIMESTAMP_TO_SCN(TO_TIMESTAMP('2016-5-16:06:06','YYYY-MM-DDHH24:MI:SS'))

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

                                                                 2599788

2)確定事務級要執行的精細邏輯恢復操作

通過LogMiner可以取得任何用戶的DML操作及相應的UNDO操作,通過執行UNDO操作可以取消用戶的錯誤操作。

3)執行后續審計

通過LogMiner可以跟蹤Oracle數據庫的所有DMLDDLDCL操作,從而取得執行這些操作的時間順序、執行這些操作的用戶等信息。

 

追加日志

  重做日志用于實現例程恢復和介質恢復,這些操作所需要的數據被自動記錄在重做日志中。但是,重做應用可能還需要記載其他列信息到重做日志中,記錄其他列的日志過程被稱為追加日志。

  默認情況下,Oracle數據庫沒有開啟追加日志,從而導致默認情況下LogMiner無法支持以下特征:

  1)索引簇、鏈行和遷移行;

  2)直接路徑插入;

  3)摘取LogMiner字典到重做日志;

  4)跟蹤DDL

  5)生成鍵列的SQL_REDOSQL_UNDO信息;

  6LONGLOB數據類型。

 

 

----如何修改追加日志數據模式:

SYS@test> select supplemental_log_data_min from v$database;

SUPPLEME

--------

NO

 

SYS@test> alter database add supplemental log data;

Database altered.

 

SYS@test> select supplemental_log_data_min from v$database;

SUPPLEME

--------

YES

----關閉追加日志

SYS@test> alter database drop supplemental log data;

Database altered.

 

SYS@test> select supplemental_log_data_min from v$database;

SUPPLEME

--------

NO

2環境準備(數據誤delete后并commit)

SYS@test> create user shall identified by shall;

User created.

SYS@test> grant connect,resource to shall;

Grant succeeded.

 

SHALL@test> create table test(id number,name varchar2(20));

Table created.

SHALL@test> begin

  2  for i in 1..100000 loop

  3  insert into test values(i,'zhong');

  4  end loop;

  5  commit;

  6  end;

  7  /

PL/SQL procedure successfully completed.

 

 

SHALL@test> select count(*) from test;

  COUNT(*)

----------

    100000

 

SHALL@test> select * from test where id = 999;

        ID NAME

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

       999 zhong

 

SHALL@test> delete test;

100000 rows deleted.

 

SHALL@test> commit;

Commit complete.

 

SHALL@test> select * from test;

no rows selected

3開始數據挖掘找回已提交的刪除數據

1)數據庫是關閉追加日志狀態:

SYS@test> select supplemental_log_data_min from v$database;

SUPPLEME

--------

NO

2)查詢庫redo位置

SYS@test> select member from v$logfile;

MEMBER

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

/u01/app/oracle/oradata/orcl/redo01_1.log

/u01/app/oracle/oradata/orcl/redo02_1.log

/u01/app/oracle/oradata/orcl/redo03_1.log

3)生成日志挖掘隊列

SYS@test> exec dbms_logmnr.add_logfile ('/u01/app/oracle/oradata/orcl/redo01_1.log');

PL/SQL procedure successfully completed.

 

SYS@test> exec dbms_logmnr.add_logfile ('/u01/app/oracle/oradata/orcl/redo02_1.log');

PL/SQL procedure successfully completed.

 

SYS@test> exec dbms_logmnr.add_logfile ('/u01/app/oracle/oradata/orcl/redo03_1.log');

PL/SQL procedure successfully completed.

 

----如果剛做了誤操作,日志未切換,可以只添加當前redo

SYS@test> select group#,status from v$log;

    GROUP# STATUS

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

         1 INACTIVE

         2 INACTIVE

         3 CURRENT

SYS@test> col member for a50

SYS@test> select group#,member,type from v$logfile;

    GROUP# MEMBER                                             TYPE

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

         1 /u01/app/oracle/oradata/orcl/redo01_1.log          ONLINE

         2 /u01/app/oracle/oradata/orcl/redo02_1.log          ONLINE

         3 /u01/app/oracle/oradata/orcl/redo03_1.log          ONLINE

4)開始挖掘

SYS@test> exec dbms_logmnr.start_logmnr(options=>dbms_logmnr.dict_from_online_catalog);

PL/SQL procedure successfully completed.

5)從v$logmnr_contents查前滾SQL和反算回來的回滾SQL

SYS@test> select sql_redo from v$logmnr_contents where lower(sql_redo) like '%delete%' and seg_name='TEST';

 

redo數據如下:

SQL_REDO

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

delete from "SHALL"."TEST" where "ID" = '42016' and "NAME" = 'zhong' and ROWID =

 'AAAWGEAAEAAAOSfABL';

delete from "SHALL"."TEST" where "ID" = '42017' and "NAME" = 'zhong' and ROWID =

 'AAAWGEAAEAAAOSfABM';

delete from "SHALL"."TEST" where "ID" = '42018' and "NAME" = 'zhong' and ROWID =

 'AAAWGEAAEAAAOSfABN';

delete from "SHALL"."TEST" where "ID" = '42019' and "NAME" = 'zhong' and ROWID =

 

 

undo數據如下:

SYS@test> select sql_redo from v$logmnr_contents where lower(sql_undo) like '%delete%' and seg_name='TEST';

SQL_REDO

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

insert into "SHALL"."TEST"("ID","NAME") values ('5039','zhong');

insert into "SHALL"."TEST"("ID","NAME") values ('5040','zhong');

insert into "SHALL"."TEST"("ID","NAME") values ('5041','zhong');

insert into "SHALL"."TEST"("ID","NAME") values ('5042','zhong');

insert into "SHALL"."TEST"("ID","NAME") values ('5043','zhong');

insert into "SHALL"."TEST"("ID","NAME") values ('5044','zhong');

insert into "SHALL"."TEST"("ID","NAME") values ('5045','zhong');

insert into "SHALL"."TEST"("ID","NAME") values ('5046','zhong');

 

 

SYS@test> set linesize 200

SYS@test> set pagesize 10000

SYS@test> create table shall as select sql_redo from v$logmnr_contents where lower(sql_undo) like '%delete%' and seg_name='TEST';

SYS@test> select * from shall;


6)最后結束挖掘:

SYS@test> EXECUTE DBMS_LOGMNR.END_LOGMNR;

PL/SQL procedure successfully completed.

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

永善县| 堆龙德庆县| 浦东新区| 德钦县| 龙陵县| 东乡族自治县| 北川| 锦屏县| 焦作市| 衡阳县| 沧源| 班戈县| 广昌县| 临沂市| 贵州省| 余干县| 宜良县| 方正县| 建始县| 永川市| 广汉市| 合江县| 武山县| 金秀| 永昌县| 双城市| 石景山区| 曲沃县| 同仁县| 定日县| 漯河市| 丰城市| 望奎县| 丹凤县| 甘洛县| 钟祥市| 舒城县| 临西县| 广安市| 石景山区| 商南县|