Flashback database

Flashback Database

Configure the following database settings before enabling Flashback Database:

    Your database must be running in ARCHIVELOG mode, because archived logs are used in the Flashback Database operation.

    You must have a fast recovery area enabled, because flashback logs can only be stored in the fast recovery area.

    For Oracle Real Application Clusters (Oracle RAC) databases, the fast recovery area must be in a clustered file system or in ASM.

Prerequisites

You must have the SYSDBA system privilege.

A flash recovery area must have been prepared for the database.

The database must have been put in FLASHBACK mode with an ALTER DATABASE FLASHBACK ON statement unless you are flashing the database back to a guaranteed restore point.

The database must be mounted but not open.

Limitations&Notes of Flashback Database

Flashback Writer (RVWR) Behavior with I/O Errors

When flashback is enabled or when there are guaranteed restore points, the background process RVWR writes flashback data to flashback database logs in the fast recovery area. If RVWR encounters an I/O error, then the following behavior is expected:

  1. If there are any guaranteed restore points defined, then the instance fails when RVWR encounters I/O errors.
  2. If no guaranteed restore points are defined, then the instance remains unaffected when RVWR encounters I/O errors. Note the following cases:
    • On a primary database, Oracle Database automatically disables Flashback Database while the database is open. All existing transactions and queries proceed unaffected. This behavior is expected for both single-instance and Oracle RAC databases. On a physical or logical standby, RVWR appears to have stopped responding, retrying the I/O periodically. This may eventually cause the logical standby or the managed recovery of the physical standby to suspend. (Oracle Database does not cause the standby instance to fail because it does not want to cause the primary database to fail in maximum protection mode.) To resolve the issue, you can issue either a SHUTDOWN ABORT or an ALTER DATABASE FLASHBACK OFF command.

Enabling Flashback Database

SQL> SELECT ESTIMATED_FLASHBACK_SIZE FROM V$FLASHBACK_DATABASE_LOG;

To enable flashback logging

ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=4320; # 3 days
# By default DB_FLASHBACK_RETENTION_TARGET is set to 1 day (1440 minutes).

ALTER DATABASE FLASHBACK ON;

Monitor logging in the Flashback Database logs

  # Monitor logging in the Flashback Database logs:
SQL> select begin_time, flashback_data,
db_data, redo_data, ESTIMATED_FLASHBACK_SIZE
from   v$flashback_database_stat;

  # Monitor the Flashback Database retention target:
SQL> select * from   v$flashback_database_log;

Disabling Flashback Database Logging

On a database instances that is either in mount or open state, issue the following command:

ALTER DATABASE FLASHBACK OFF;

Creating Normal and Guaranteed Restore Points

To create a restore point:

SQL> CREATE RESTORE POINT before_upgrade;

SQL> CREATE RESTORE POINT before_upgrade GUARANTEE FLASHBACK DATABASE;

List RESTORE POINT

LIST RESTORE POINT ALL;

SQL> SELECT NAME, SCN, TIME, DATABASE_INCARNATION#,GUARANTEE_FLASHBACK_DATABASE,STORAGE_SIZE FROM V$RESTORE_POINT;

Drop RESTORE POINT

SQL> DROP RESTORE POINT before_app_upgrade;

Flashback Example

Set the environment to correct instance

ps -ef | grep pmon
. oraenv

Get restore point name and make note of it from sqlplus

SQL> select name, host_name, status from gv$instance;
SQL> select log_mode,flashback_on from v$database;
SQL> select name,time from v$restore_point;

Stop the database and put it in mount state using srvctl

srvctl status database -d MYTESTDB
srvctl stop database -d MYTESTDB
srvctl status database -d MYTESTDB
srvctl start instance -d MYTESTDB -i MYTESTDB1 -o mount

Flashback to restore point using sqlplus

SQL> select instance_name,status from gv$instance;

SQL> flashback database to restore point REST_POINT;

SQL> alter database open resetlogs;

Database altered.

Stop and start the database and make sure all instances are up, using srvctl

srvctl stop database -d MYTESTDB
srvctl start database -d MYTESTDB
srvctl status database -d MYTESTDB

désert/Oracle/FRA (last edited 2019-05-23 09:10:01 by localhost)