检查是否开启归档
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
检查flashback日志中最旧的SCN
SQL> select oldest_flashback_scn from v$flashback_database_log;
no rows selected
之前没有开过,则没有返回
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.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 276824064 bytes
Fixed Size 2095640 bytes
Variable Size 100664808 bytes
Database Buffers 167772160 bytes
Redo Buffers 6291456 bytes
Database mounted.
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38709: Recovery Area is not enabled.
可以归档已经开了啊
但是报错说闪回区不可达,
SQL> show parameter recover_file_dest
没有内容,设置参数
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 276824064 bytes
Fixed Size 2095640 bytes
Variable Size 100664808 bytes
Database Buffers 167772160 bytes
Redo Buffers 6291456 bytes
Database mounted.
SQL> create pfile='/tmp/a.txt' from spfile;
File created.
SQL> exit
创建目录;
mkdir -p /u01/app/oracle/db_recover_flashback_file
在参数文件中增加参数
*.db_recovery_file_dest='/u01/app/oracle/db_recover_flashback_file';
再次启动
SQL> startup mount pfile='/tmp/a.txt'
ORA-19802: cannot use DB_RECOVERY_FILE_DEST without DB_RECOVERY_FILE_DEST_SIZE
增加参数
*.db_recovery_file_size=200M
SQL> startup pfile='/tmp/a.txt';
ORACLE instance started.
Total System Global Area 276824064 bytes
Fixed Size 2095640 bytes
Variable Size 100664808 bytes
Database Buffers 167772160 bytes
Redo Buffers 6291456 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile='/tmp/a.txt';
File created.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 276824064 bytes
Fixed Size 2095640 bytes
Variable Size 100664808 bytes
Database Buffers 167772160 bytes
Redo Buffers 6291456 bytes
Database mounted.
SQL> alter database flashback on;
Database altered.
SQL> alter database open;
Database altered.
设置成功;
总结:
在开启归档的时候,必须在mount状态下,不仅需要开启归档日志,还需要设置DB_RECOVERY_FILE_DEST和DB_RECOVERY_FILE_DEST_SIZE两个参数!
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
检查flashback日志中最旧的SCN
SQL> select oldest_flashback_scn from v$flashback_database_log;
no rows selected
之前没有开过,则没有返回
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.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 276824064 bytes
Fixed Size 2095640 bytes
Variable Size 100664808 bytes
Database Buffers 167772160 bytes
Redo Buffers 6291456 bytes
Database mounted.
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38709: Recovery Area is not enabled.
可以归档已经开了啊
但是报错说闪回区不可达,
SQL> show parameter recover_file_dest
没有内容,设置参数
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 276824064 bytes
Fixed Size 2095640 bytes
Variable Size 100664808 bytes
Database Buffers 167772160 bytes
Redo Buffers 6291456 bytes
Database mounted.
SQL> create pfile='/tmp/a.txt' from spfile;
File created.
SQL> exit
创建目录;
mkdir -p /u01/app/oracle/db_recover_flashback_file
在参数文件中增加参数
*.db_recovery_file_dest='/u01/app/oracle/db_recover_flashback_file';
再次启动
SQL> startup mount pfile='/tmp/a.txt'
ORA-19802: cannot use DB_RECOVERY_FILE_DEST without DB_RECOVERY_FILE_DEST_SIZE
增加参数
*.db_recovery_file_size=200M
SQL> startup pfile='/tmp/a.txt';
ORACLE instance started.
Total System Global Area 276824064 bytes
Fixed Size 2095640 bytes
Variable Size 100664808 bytes
Database Buffers 167772160 bytes
Redo Buffers 6291456 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile='/tmp/a.txt';
File created.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 276824064 bytes
Fixed Size 2095640 bytes
Variable Size 100664808 bytes
Database Buffers 167772160 bytes
Redo Buffers 6291456 bytes
Database mounted.
SQL> alter database flashback on;
Database altered.
SQL> alter database open;
Database altered.
设置成功;
总结:
在开启归档的时候,必须在mount状态下,不仅需要开启归档日志,还需要设置DB_RECOVERY_FILE_DEST和DB_RECOVERY_FILE_DEST_SIZE两个参数!