数据库Flashback学习
Posted bugbeta
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据库Flashback学习相关的知识,希望对你有一定的参考价值。
最近更新时间:2018/12/18
适用场景
数据库升级、快速构建测试环境、DG中重建主库
前置条件
1. ARCHIVELOG 模式
数据库为 mount 状态下开启,最好指定archive log 保存路径。
alter system set log_archive_dest_1=‘location=/u01/arch‘;
ALTER DATABASE ARCHIVELOG;
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/arch
Oldest online log sequence 0
Next log sequence to archive 0
Current log sequence 54
2. 使用时Database要为mount状态,Control File为当前在用的,不是通过备份恢复或者其他方式创建的,因为通过备份恢复或其他方式创建的控制文件不含 flashback log相关信息;
3. 所有在线表空间不存在禁用flashback的情况(ALTER TABLESPACE ... FLASHBACK OFF)
参数说明
1. 设置 Fast Recovery Area,FRA为ORACLE提供集中管理备份恢复文件路径
1.1 DB_RECOVERY_FILE_DEST 设置默认FRA路径
1.2 DB_RECOVERY_FILE_DEST_SIZE 设置配额(BYTES)
2. DB_FLASHBACK_RETENTION_TARGET 设置保留策略,只是期望值,具体与闪回区保留数据有关
3. 通过Flashback闪回数据库后,使用 ALTER DATABASE OPEN RESETLOGS 打开数据库
参考: http://docs.oracle.com/cd/E11882_01/backup.112/e10642/flashdb.htm#BRADV71000
SQL> show parameter db_recovery
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/fast_recovery_area
db_recovery_file_dest_size big integer 500M
开启方式
STARTUP MOUNT;
ALTER DATABASE FLASHBACK ON;
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
YES
常用查询
闪回区空间使用情况
select * from v$flash_recovery_area_usage;
问题
FRA空间不足
Completed: alter database open
Wed Dec 19 17:21:09 2018
Errors in file /u01/app/diag/rdbms/db2/orcl/trace/orcl_m000_6773.trc:
ORA-19815: WARNING: db_recovery_file_dest_size of 524288000 bytes is 100.00% used, and has 0 remaining bytes available.
************************************************************************
You have following choices to free up space from recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
system command was used to delete files, then use RMAN CROSSCHECK and
DELETE EXPIRED commands.
************************************************************************
解决: 增加空间
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 4G scope=both;
以上是关于数据库Flashback学习的主要内容,如果未能解决你的问题,请参考以下文章
[Oracle维护工程师手记系列]为什么flashback 的时候既需要 flashback log ,又需要 archive log?