Physical Standby上開啟flashback database實驗日誌
閃回資料庫的主要作用是針對資料庫的邏輯錯誤,比如使用者誤運算元據,drop或者truncate表之類的,如果你的資料庫是一個DataGuard環境,那麼在Standby上開啟閃回有幾點好處:
1.不影響主庫效能的情況下還能使用閃回資料庫的功能。
2.備庫閃回後以read only方式開啟然後將需要的資料匯出,最後open備庫繼續應用日誌,整個過程不影響主庫執行,並且不破壞當前DataGuard環境。
有關閃回資料庫的幾個引數說明:
db_flashback_retention_target
該引數指定了資料庫能夠閃回到過去多久的時間,單位是分鐘。預設值為1440,即24小時。
db_recovery_file_dest_size
該
引數指定了快速恢復區能夠使用的最大容量值。該值可以根據資料庫的redo產生量或者資料改動量進行設定。如果快速恢復區的使用率為100%,並且歸檔日
志或者備份集存在於該區域中的話,那麼資料庫會因為無法歸檔等原因而hang住。如果只儲存flashback
log的話,是不會因為使用率為100%而hang住的。
db_recovery_file_dest
該引數指定了快速恢復區的位置。
flashback
log是迴圈寫的,有點像redo log,它必須存放在快速恢復區下,並且空間使用是由Oracle自動管理的,如果由於flashback
log產生過多或者快速恢復區使用率達到100%,則Oracle會自動收縮flashback
log,這樣可能無法保證能夠閃回至db_flashback_retention_target值。
實驗環境主庫是2節點RAC,備庫為單例項:
os version: Red Hat Linux 5.5 32bit
rdbms version: Oracle 11.2.0.4
下面是在Physical Standby上開啟flashback的步驟:
SYS@pcendbas>alter system set db_flashback_retention_target=240;
System altered.
System altered.
SYS@pcendbas>alter system set db_recovery_file_dest_size=1g;
System altered.
SYS@pcendbas>alter system set db_recovery_file_dest='+ORADATA1';
System altered.
SYS@pcendbas>select force_logging,flashback_on from v$database;
FOR FLASHBACK_ON
--- ------------------
NO NO
System altered.
SYS@pcendbas>alter system set db_recovery_file_dest='+ORADATA1';
System altered.
SYS@pcendbas>select force_logging,flashback_on from v$database;
FOR FLASHBACK_ON
--- ------------------
NO NO
SYS@pcendbas>alter database force logging;
Database altered.
Database altered.
SYS@pcendbas>alter database flashback on ;
Database altered.
Database altered.
SYS@pcendbas>select force_logging,flashback_on from v$database;
FOR FLASHBACK_ON
--- ------------------
YES YES
FOR FLASHBACK_ON
--- ------------------
YES YES
SYS@pcendbas>select * from v$flash_recovery_area_usage;
FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
-------------------- ------------------ ------------------------- ---------------
CONTROL FILE 1.76 0 1
REDO LOG 0 0 0
ARCHIVED LOG 0 0 0
BACKUP PIECE .2 0 1
IMAGE COPY 0 0 0
FLASHBACK LOG 9.96 0 2
FOREIGN ARCHIVED LOG 0 0 0
7 rows selected.
FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
-------------------- ------------------ ------------------------- ---------------
CONTROL FILE 1.76 0 1
REDO LOG 0 0 0
ARCHIVED LOG 0 0 0
BACKUP PIECE .2 0 1
IMAGE COPY 0 0 0
FLASHBACK LOG 9.96 0 2
FOREIGN ARCHIVED LOG 0 0 0
7 rows selected.
SYS@pcendbas>alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.
SYS@pcendbas>select * from v$flashback_database_log;
OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TI RETENTION_TARGET FLASHBACK_SIZE ESTIMATED_FLASHBACK_SIZE
-------------------- ------------------- ---------------- -------------- ------------------------
1323031 2016-05-15 06:51:15 240 104857600 60657664
Session altered.
SYS@pcendbas>select * from v$flashback_database_log;
OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TI RETENTION_TARGET FLASHBACK_SIZE ESTIMATED_FLASHBACK_SIZE
-------------------- ------------------- ---------------- -------------- ------------------------
1323031 2016-05-15 06:51:15 240 104857600 60657664
在主庫端新建3個表作為測試,分別對3個表進行delete,drop,truncate,然後閃回資料庫,最後再開啟redo apply.
create table test1 (id int,name varchar2(10));
insert into test1 values (1,'xx');
create table test2 (id int,name varchar2(10));
insert into test2 values (2,'xx');
create table test3 (id int,name varchar2(10));
insert into test3 values (3,'xx');
commit;
insert into test1 values (1,'xx');
create table test2 (id int,name varchar2(10));
insert into test2 values (2,'xx');
create table test3 (id int,name varchar2(10));
insert into test3 values (3,'xx');
commit;
SYS@pcendbas>select sysdate from dual;
SYSDATE
-------------------
2016-05-17 21:12:47
模擬使用者對3張表的誤操作
SYSDATE
-------------------
2016-05-17 21:12:47
模擬使用者對3張表的誤操作
SQL> delete from test1;
1 row deleted.
SQL> commit;
Commit complete.
SQL> drop table test2 purge;
Table dropped.
SQL> truncate table test3;
1 row deleted.
SQL> commit;
Commit complete.
SQL> drop table test2 purge;
Table dropped.
SQL> truncate table test3;
在standby端進行閃回,並進行資料驗證
SYS@pcendbas>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@pcendbas>startup mount
ORACLE instance started.
Total System Global Area 627732480 bytes
Fixed Size 1366444 bytes
Variable Size 511706708 bytes
Database Buffers 109051904 bytes
Redo Buffers 5607424 bytes
Database mounted.
SYS@pcendbas>flashback standby database to timestamp to_timestamp('2016-05-17 21:12:47','yyyy-mm-dd hh24:mi:ss');
Flashback complete.
SYS@pcendbas>alter database open read only;
Database altered.
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@pcendbas>startup mount
ORACLE instance started.
Total System Global Area 627732480 bytes
Fixed Size 1366444 bytes
Variable Size 511706708 bytes
Database Buffers 109051904 bytes
Redo Buffers 5607424 bytes
Database mounted.
SYS@pcendbas>flashback standby database to timestamp to_timestamp('2016-05-17 21:12:47','yyyy-mm-dd hh24:mi:ss');
Flashback complete.
SYS@pcendbas>alter database open read only;
Database altered.
SYS@pcendbas>select * from test1;
ID NAME
---------- ----------
1 xx
SYS@pcendbas>select * from test2;
ID NAME
---------- ----------
2 xx
SYS@pcendbas>select * from test3;
ID NAME
---------- ----------
3 xx
ID NAME
---------- ----------
1 xx
SYS@pcendbas>select * from test2;
ID NAME
---------- ----------
2 xx
SYS@pcendbas>select * from test3;
ID NAME
---------- ----------
3 xx
接下來就可以對資料進行匯出,匯出之後以open方式開啟資料庫,可以繼續進行redo apply,直至與主庫同步。
SYS@pcendbas>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@pcendbas>startup
ORACLE instance started.
Total System Global Area 627732480 bytes
Fixed Size 1366444 bytes
Variable Size 511706708 bytes
Database Buffers 109051904 bytes
Redo Buffers 5607424 bytes
Database mounted.
Database opened.
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@pcendbas>startup
ORACLE instance started.
Total System Global Area 627732480 bytes
Fixed Size 1366444 bytes
Variable Size 511706708 bytes
Database Buffers 109051904 bytes
Redo Buffers 5607424 bytes
Database mounted.
Database opened.
SYS@pcendbas>alter database recover managed standby database using current logfile disconnect from session;
Database altered.
Database altered.
SYS@pcendbas>select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 139
2 115
THREAD# MAX(SEQUENCE#)
---------- --------------
1 139
2 115
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26753337/viewspace-2101734/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle實驗記錄 (flashback,physical standby resetlogs)Oracle
- oracle實驗記錄 (physical standby 日誌應用方面)Oracle
- 在Oracle DG Standby庫上啟用flashback database功能OracleDatabase
- Convert a Physical Standby Database into a Snapshot Standby DatabaseDatabase
- Physical Standby Database 切換到 Snapshot Standby DatabaseDatabase
- 【DataGuarad】ORA-1153 trying to turn on Flashback for Physical Standby DatabaseDatabase
- Oracle DG建立Physical Standby DatabaseOracleDatabase
- Creating a Physical Standby DatabaseDatabase
- Performing a Failover to a Physical Standby DatabaseORMAIDatabase
- Oracle10G Physical Standby Database setupOracleDatabase
- Performing a Switchover to a Physical Standby Database and failoverORMDatabaseAI
- oracle 9i physical standby database 上的v$archived_logOracleDatabaseHive
- [Flashback]Flashback Database閃回資料庫實驗Database資料庫
- 【Flashback】Flashback Database閃回資料庫功能實驗Database資料庫
- ORACLE10g DataGuard 配置Physical Standby DatabaseOracleDatabase
- oracle 10g physical standby database creationOracle 10gDatabase
- Recover physical standby database after loss of archive log(2)DatabaseHive
- 同事總結的 : 用RMAN建立Physical Standby DatabaseDatabase
- 一次oracle 9i physical standby database 的監聽未啟動導致的主庫日誌傳輸不到目的端OracleDatabase
- oracle10g data guard(dg)__flashback_physical databaseOracleDatabase
- oracle 9i physical standby database 的源端正常傳輸歸檔日誌到目的端的條件OracleDatabase
- 啟用flashback database 功能Database
- oracle 9i physical standby database狀態查詢OracleDatabase
- Using RMAN Incremental Backups to Roll Forward a Physical Standby DatabaseREMForwardDatabase
- Brief description of Oracle physical standby database configuration and managementOracleDatabase
- Brief description of Oracle physical standby database configuration and managemeOracleDatabase
- Recover physical standby database after loss of archive log – roll forward(轉)DatabaseHiveForward
- Bug 13250486 : ADD STANDBY DATABASE FOR TARGET WITH FLASHBACK ON FAILS WITH ERRDatabaseAI
- Oracle 10g FLASHBACK DATABASE 實驗記錄Oracle 10gDatabase
- Oracle physical standbyOracle
- Creating a Physical Standby using RMAN DUPLICATE FROM ACTIVE DATABASEDatabase
- ORACLE10G DG配置下Physical Standby Database的管理OracleDatabase
- oracle 9i physical standby database 中v$database switchover_status的含義OracleDatabase
- 【Flashback】啟用Flashback Database閃回資料庫功能Database資料庫
- Step By Step Guide To Create Physical Standby Database Using RMAN [ID 469493.1]GUIIDEDatabase
- DataGuard:Physical Standby Switchover
- Physical Database LimitsDatabaseMIT
- Flashback DatabaseDatabase