Oracle 11gr1打开数据库的闪回flashback
打开数据库flashback
1. 确认一个数据库是否打开了flashback,有两个简单的方法:
(1)直接查数据库
SQL> select name,log_mode,flashback_on from v$database;
NAME LOG_MODE FLASHBACK_ON
--------- ------------ ------------------
ORA11G ARCHIVELOG NO --> flashback未打开
2. 如果数据库没有打开flashback,那么将flashback打开:
(1)确定flashback的存储路径
SQL> show parameter recovery
NAME TYPE VALUE
----------------------------- ----------- ------------------------------
db_recovery_file_dest string
db_recovery_file_dest_size big integer 0
recovery_parallelism integer 0
修改db_recovery_file_dest:
SQL> alter system set db_recovery_file_dest = '/home/oracle/flashback' scope = both;
alter system set db_recovery_file_dest = '/home/oracle/flashback' scope = both
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-19802: cannot use DB_RECOVERY_FILE_DEST without DB_RECOVERY_FILE_DEST_SIZE
上面的错误,是因为在设置db_recovery_file_dest之前,一定要先设置db_recovery_file_dest_size,于是:
SQL> alter system set db_recovery_file_dest_size = 20G scope =both;
System altered.
SQL> show parameter recovery
NAME TYPE VALUE
------------------------------- ----------- ------------------------------
db_recovery_file_dest string
db_recovery_file_dest_size big integer 20G
recovery_parallelism integer 0
SQL> alter system set db_recovery_file_dest = '/home/oracle/flashback' scope = both;
System altered.
SQL> show parameter recovery
NAME TYPE VALUE
------------------------------- ----------- ------------------------------
db_recovery_file_dest string /home/oracle/flashback
db_recovery_file_dest_size big integer 20G
recovery_parallelism integer 0
(2)打开flashback
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38759: Database must be mounted by only one instance and not open.
上面的错误,是因为在打开数据库的flashback必须要mount状态下方可以,于是:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 5344731136 bytes
Fixed Size 2169104 bytes
Variable Size 2130708208 bytes
Database Buffers 3204448256 bytes
Redo Buffers 7405568 bytes
Database mounted.
SQL> alter database flashback on;
Database altered.
SQL> alter database open;
Database altered.
SQL> select name,log_mode,flashback_on from v$database;
NAME LOG_MODE FLASHBACK_ON
--------- ------------------ ------------
ORA11G ARCHIVELOG YES