閃回資料庫-- Doc ID 249319.1

lovestanford發表於2014-04-15

本文介紹瞭如何配置資料庫,使其能進行資料庫閃回flashback database,
Flashback database
-----------------------------
- This a new feature introduced in 10g.
- Flashbacking a database means going back to a previous database state.
- The Flashback Database feature provides a way to quickly revert entire
Oracle database to the state it was in at a past point in time.
- This is different from traditional point in time recovery.
- A new background process RVWR introduced which is responsible for writing
flashback logs which stores pre-image(s) of data blocks
- One can use Flashback Database to back out changes that:
- Have resulted in logical data corruptions.
- Are a result of user error.
- This feature is not applicable for recovering the database in case of media
failure.
- The time required for flashbacking a database to a specific time in past is
DIRECTLY PROPORTIONAL to the number of changes made and not on the size
of the database.

How to Configure Flashback database
------------------------------------
Prerequisites 前提條件
--------------
a) Database must be in archivelog mode.
b) Last clean shutdown.
c) Enterprise and Personal Edition required

Configuration: -引數配置
---------------
Initialization Parameters required: -
a) DB_RECOVERY_FILE_DEST (dynamically modifiable) --&gt Physical location where RVWR background process
writes flashback logs.
b) DB_RECOVERY_FILE_DEST_SIZE (dynamically modifiable) --&gt Maximum size flashback logs can occupy in
DB_RECOVERY_FILE_DEST.
c) DB_FLASHBACK_RETENTION_TARGET (dynamically modifiable) --&gt upper limit in minutes on how far back
one can flashback the database.

After setting these parameters in parameter file(init.ora) or spfile.

Note:- Clean shutdown is mandatory.
修改上述引數之後,關閉資料庫 shutdown immediate;然後

SQL> Startup mount;

SQL> Alter database flashback on;

SQL> Alter database open;

SQL> select flashback_on from v$database;
FLASHBACK_ON
------------
YES



To see the background process :-

$ ps -eaf | grep rvwr
oracle 10302 1 0 10:58:09 ? 0:00 ora_rvwr_db10g
oracle 22353 12428 1 13:31:16 pts/tL 0:00 grep rvwr



The above two output confirms that the datbase has its flashback feature ON.

如何閃回資料庫,
可以指定 scn ,timestamp ,logseq
下面展示瞭如何進行閃回。
How to Flashback the database to the previous state on basis of :
----------------------------------------------------------------
a) SCN
b) Timestamp
c) Log Sequence Number

State 1 State 2
------- -------
| | >--------------- | |
| | flashback | |
------- -------
SCN=100 SCN=150

Timestamp=12-09-2003:10:00:00 Timestamp=12-09-2003:12:00:00

Log Sequence Number= 50 Log Sequence Number= 55

Using SCN :-
----------

SQL> shutdown immediate
SQL> startup mount
SQL> flashback database to SCN 100;

Flashback complete.

SQL> alter database open resetlogs;

Database altered.



Note:- This feature can be used with RMAN or Enterprise Manager also.

Using Timestamp :-
---------------

SQL> shutdown immediate
SQL> startup mount
SQL> flashback database to TIMESTAMP(sysdate - 2/24);

Flashback complete.

SQL> alter database open resetlogs;

Database altered.



Using Log sequence Number and RMAN
----------------------------------

RMAN> flashback database to sequence=50 thread=1;

RMAN> alter database open resetlogs;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21754115/viewspace-1142821/,如需轉載,請註明出處,否則將追究法律責任。

相關文章