flash recovery area配置
检查数据库是否开启闪回:
SQL> select flashback_on from v$database; FLASHBACK_ON ------------------------------------ YES
打开闪回区,必须要将数据库在mount阶段才能开启,否则会报错,如下:
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> 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.
将数据库修改为归档模式:
SQL> alter database archivelog; Database altered
在mount阶段,在归档模式下,打开闪回区:
SQL> alter database open; Database altered.
查看数据库能闪回到最早的SCN:
SQL> select oldest_flashback_scn,oldest_flashback_time from v$flashback_database_log; OLDEST_FLASHBACK_SCN OLDEST_FLASH -------------------- ------------ 648133 13-JUL-14
查看配置的基本参数:
SQL> show parameter db_recovery_file NAME TYPE VALUE ------------------------------------ -------- ------------------------------ db_recovery_file_dest string +RECOVER db_recovery_file_dest_size big inte 2G ger
数据库可以恢复到多少分钟前的,默认是一天
SQL> show parameter flash NAME TYPE VALUE ------------------------------------ -------- ------------------------------ db_flashback_retention_target integer 1440
使用flash back area需要在初始化参数中定义两个参数,db_recovery_file_dest定义的是闪回区的位置,db_recovery_file_dest_size定义的是闪回区的大小,在RAC环境下配置时,需要保证每个节点的值是相同的:
修改这两个参数的时候,可以在线进行修改,如下:
SQL> alter system set db_recovery_file_dest = '+ASM' scope=both; System altered. SQL> alter system set db_recovery_file_dest_size='5g' scope=both sid='*'; System altered.
在使用ASM作为闪回区的位置时,只能指定到磁盘组级别,而不能是某个目录,因为ASM使用的是OMF进行管理的,会自动进行目录的创建:
SQL> alter system set db_recovery_file_dest='+recovery/test' scope=both; alter system set db_recovery_file_dest='+recovery/test' scope=both * ERROR at line 1: ORA-02097: parameter cannot be modified because specified value is invalid ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated SQL> alter system set db_recovery_file_dest='+recovery' scope=both; System altered.
监控闪回区空间的大小使用情况:
SQL> col name format a32 heading 'file name' SQL> col spc_lmt_mb format 9999.99 heading 'space|limit|(mb)' SQL> col spc_usd_mb format 9999.99 heading 'space|limit|(mb)' SQL> col spc_rcl_mb format 9999.99 heading 'reclm|space|(mb)' SQL> col spc_usd_mb format 9999.99 heading 'space|used|(mb)' SQL> col number_of_files format 99999 heading 'files' SQL> select name,space_limit/(1024*1024) spc_lmt_mb,space_used/(1024*1024) spc_usd_mb,space_reclaimable/(1024*1024) spc_rcl_mb,number_of_files from v$recovery_file_dest; space space reclm limit used space file name (mb) (mb) (mb) files -------------------------------- -------- -------- -------- ------ +recovery 5120.00 165.20 .00 5
如果空间使用率到达85%,在alert日志中可以看到waring的日志,如果超过了97%,会记录一条critical warning日志。告警日志查看:
SQL> select reason,object_type,suggested_action from dba_outstanding_alerts;
查看是什么文件占用了空间:
SQL> select * from v$flash_recovery_area_usage; FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE files ------------------------ ------------------ ------------------------- ------ CONTROLFILE .13 0 1 ONLINELOG 2.93 0 3 ARCHIVELOG 0 0 0 BACKUPPIECE 0 0 0 IMAGECOPY 0 0 0 FLASHBACKLOG .15 0 1 6 rows selected.
在oracle11g的默认情况下,归档日志是保存在flash back area中的,因此如果空间不够,那么将会造成归档日志无法归档,从而删除过期的归档日志即可:
使用RMAN删除过期归档日志:
[oracle@kel ~]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Mon Jul 14 00:08:02 2014 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: OMF (DBID=680034237) RMAN> crosscheck archivelog all; using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=154 devtype=DISK validation succeeded for archived log archive log filename=+RECOVER/omf/1_1_852236226.dbf recid=1 stamp=852320500 validation succeeded for archived log archive log filename=+RECOVER/omf/1_2_852236226.dbf recid=2 stamp=852423499 validation succeeded for archived log archive log filename=+RECOVER/omf/1_3_852236226.dbf recid=3 stamp=852579011 validation succeeded for archived log archive log filename=+RECOVER/omf/1_4_852236226.dbf recid=4 stamp=852840609 Crosschecked 4 objects RMAN> delete expired archivelog all; released channel: ORA_DISK_1 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=154 devtype=DISK specification does not match any archive log in the recovery catalog
for linux and python