您好,登錄后才能下訂單哦!
生產上要做災備系統的應急切換演練,災備端是由OGG搭建的。由于生產庫都比較大10多T,不想演練后重新初始化災備庫,生產庫版本為10.2.0.4,于是想到10g的新特性flashback database。演練開始前記錄一個還原點,演練結束后閃回到這個還原點,重新同步ogg即可。
測試閃加數據庫。
一、開啟FLASHBACK DATABASE
數據庫版本:10.2.0.4
啟用FLASHBACK DATABASE數據庫必須為ARCHIVELOG模式,還需要有一個閃回恢復區用于存儲閃回日志,RAC中閃回恢復區必須在集群文件系統或ASM中。
--數據庫已開啟歸檔,但還未啟用FLASHBACK SQL> select flashback_on,log_mode from v$database; FLASHBACK_ON LOG_MODE ------------------------------------------------------ ------------------------------------ NO ARCHIVELOG --調整參數 SQL> alter system set db_recovery_file_dest_size=3G scope=spfile; System altered. SQL> alter system set db_recovery_file_dest='/u01/app/oracle/flashback_area/' scope=spfile; System altered. SQL> alter system set db_flashback_retention_target=2880 scope=spfile; System altered. --關閉數據庫 SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. --啟動到mount狀態,開啟FLASHBACK SQL> startup mount; ORACLE instance started. Total System Global Area 599785472 bytes Fixed Size 2085776 bytes Variable Size 192941168 bytes Database Buffers 398458880 bytes Redo Buffers 6299648 bytes Database mounted. SQL> alter database flashback on; Database altered. --啟動數據庫 SQL> alter database open; Database altered. --查看新狀態 SQL> select flashback_on,log_mode from v$database; FLASHBACK_ON LOG_MODE ------------------------------------------------------ ------------------------------------ YES ARCHIVELOG
官方文檔:http://docs.oracle.com/cd/B19306_01/backup.102/b14192/rpfbdb003.htm#sthref509
db_recovery_file_dest_size參數表示閃回恢復區的大小
db_recovery_file_dest參數表示閃回恢復區目錄
db_flashback_retention_target表是閃回日志保留的時間,單位為分,默認1440(1天)
查看閃回恢復區里已生成閃回日志
[oracle@rhel5 flashback_area]$ cd /u01/app/oracle/flashback_area/MYDB/flashback/ [oracle@rhel5 flashback]$ ls -l total 8020 -rw-r----- 1 oracle oinstall 8200192 Jan 9 14:48 o1_mf_d76cxc1r_.flb
二、創建測試表
SQL> conn zx/zx Connected. SQL> create table flash_t as select * from all_tables; Table created. SQL> insert into flash_t select * from flash_t; 1559 rows created. SQL> / 3118 rows created. SQL> commit; Commit complete. SQL> select count(*) from flash_t; COUNT(*) ---------- 6236
三、查看數據庫可以閃回的時間點
SQL> select * from V$FLASHBACK_DATABASE_LOG; OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_ RETENTION_TARGET FLASHBACK_SIZE ESTIMATED_FLASHBACK_SIZE -------------------- ----------------- ---------------- -------------- ------------------------ 7762668 20170109 14:37:32 2880 14467072 590954496
四、測試閃回數據庫到一個時間點
--記錄當前SCN用于閃回數據庫 SQL> SELECT CURRENT_SCN FROM V$DATABASE; CURRENT_SCN ----------- 7765990 --刪除測試表 SQL> conn / as sysdba Connected. SQL> select count(*) from zx.flash_t; COUNT(*) ---------- 6236 SQL> drop table zx.flash_t; Table dropped. SQL> select count(*) from zx.flash_t; select count(*) from zx.flash_t * ERROR at line 1: ORA-00942: table or view does not exist --閃回數據庫 SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount; ORACLE instance started. Total System Global Area 599785472 bytes Fixed Size 2085776 bytes Variable Size 192941168 bytes Database Buffers 398458880 bytes Redo Buffers 6299648 bytes Database mounted. --執行閃回 SQL> flashback database to scn 7765990; Flashback complete. --以resetlogs方式打開數據庫 SQL> alter database open resetlogs; --可以使用alter database open read only打開數據庫查看閃回后數據庫的狀態,如果閃回的不理想,重啟到mount模式重新做flashback database Database altered. --驗證測試表得到恢復 SQL> select count(*) from zx.flash_t; COUNT(*) ---------- 6236
閃回還可以指定時間或還原點
FLASHBACK DATABASE TO RESTORE POINT BEFORE_CHANGES;
FLASHBACK DATABASE TO TIME "TO_DATE('09/20/00','MM/DD/YY')";官方文檔:http://docs.oracle.com/cd/B19306_01/backup.102/b14192/flashptr005.htm#BGBDCAFA
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。