如果想使用“闪回数据库”这个功能。则必须在归档模式下启用这个功能。
1.确认闪回数据库功能未开启
ora10g@secdb /home/oracle$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jun 21 21:18:07 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
sys@ora10g> show parameter recovery_file
NAME TYPE VALUE
-------------------------- ------ ------------------------------------
db_recovery_file_dest string /oracle/ora10gR2/flash_recovery_area
db_recovery_file_dest_size big integer 20G
sys@ora10g> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
2.在数据库MOUNTED状态下尝试启用闪回数据库功能
sys@ora10g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ora10g> startup mount;
ORACLE instance started.
Total System Global Area 419430400 bytes
Fixed Size 1219784 bytes
Variable Size 96469816 bytes
Database Buffers 314572800 bytes
Redo Buffers 7168000 bytes
Database mounted.
sys@ora10g> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38707: Media recovery is not enabled.
这里的“ORA-38706”和“ORA-38707”错误暗示的内容便是:你的数据库没有运行在归档模式下。
3.启用数据库到归档模式
为处理上面的报错信息,需要将数据库调整为归档模式。
sys@ora10g> alter database archivelog;
Database altered.
sys@ora10g> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 18
Next log sequence to archive 20
Current log sequence 20
4.再次尝试启用闪回数据库功能
sys@ora10g> alter database flashback on;
Database altered.
sys@ora10g> alter database open;
Database altered.
sys@ora10g> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES
到此闪回数据库功能便顺利地开启。
5.闪回数据库文件
存放在db_recovery_file_dest参数对应的目录下。
ora10g@secdb /oracle/ora10gR2/flash_recovery_area/ORA10G/flashback$ ls -l | wc -l
124
其中保存了很多以OMF方式管理的闪回文件,例如“o1_mf_6ytmhn54_.flb”等。
6.小结
闪回数据库功能毕竟是一个比较高级的恢复技术。相对其他闪回技术自然需要更多的要求。这里额外的要求便是需要数据库运行在归档模式下。对于一般的生产系统,这个要求不为过。
Good luck.
secooler
11.06.21
-- The End --