Sie sind auf Seite 1von 8

I. HOW TO CONFIGURE FLASHBACK DATABASE?

1. Before to configure Flashback Database, you must ensure that: Your database is running in ARCHIVELOG mode FRA (Flash Recovery Area) is configured FRA is configured by two parameters: o DB_RECOVERY_FILE_DEST o DB_RECOVERY_FILE_DEST_SIZE COMPATIBILITY initialization parameter is set to 10.0 or higher value 2. Consider the value for flashback database window. It can be set by an initialization parameter: DB_FLASHBACK_RETENTION_TARGET. The range of SCNs for which there is currently enough flashback log data to support the FLASHBACK DATABASE command is called the Flashback Database Window. The flashback window depends of the current environment requirement but usually it can be between 24 and 72 hours. Dont consider too big values for flashback window because if you need to perform flashback database operation to a point in time older than several days it can be slower and much more time-consuming operation than using of media recovery method. Note: The flashback retention target is not an absolute guarantee that flashback will be available. If space is needed for required files in the Flash Recovery Area, flashback logs may be deleted automatically. So Flashback Database is efficient and fast for smaller time spans when the error is immediately (or within few hours) discovered and performing of a Database Point-in-Time Recovery is the only one way to recover from this human error. Default value for DB_FLASHBACK_RETENTION_TARGET is 1440. It is measured in minutes, so by default flashback window is 24 hours. Keep in mind that flashback logs use additional space within the FRA and we can restore up to the available Flashback logs. Note: Flashback Database logs are not archived. Rather the file is backed up to tape. 3. Connect as user SYS with SYSDBA privileges. 4. Check the Database Archive mode. SQL> ARCHIVE LOG LIST Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 4 Next log sequence to archive 6 Current log sequence 6 5. Configure DB_FLASHBACK_RETENTION_TARGET: DB_RECOVERY_FILE_DEST:

DB_RECOVERY_FILE_DEST_SIZE SQL> ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=1440 SCOPE=BOTH; SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST= +disk_flash SCOPE=BOTH; SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE=1260G SCOPE=BOTH; 6. Shut down the database: SQL> SHUTDOWN IMMEDIATE 7. Start the database in MOUNT stage. To enable Flashback Database feature, your database must be in MOUNT mode. SQL> STARTUP MOUNT For RAC environments, use: SQL> STARTUP MOUNT EXCLUSIVE 8. Enable Flashback Database Feature: SQL> ALTER DATABASE FLASHBACK ON; 9. Check whether the Flashback Database feature is enabled or not: SQL> SELECT flashback_on FROM V$DATABASE; 10. Open the database with enabled Flashback Database feature: SQL> ALTER DATABASE OPEN; 11. Creating guaranteed restore point. SQL> CREATE RESTORE POINT TESTING1_2013_NOV_16_01_38 GUARANTEE FLASHBACK DATABASE;

II. USING OF FLASHBACK DATABASE TO GUARANTEED RESTORE POINT


Database can be flashed back either through SQL*Plus or RMAN. In SQL*Plus, you can use this feature by issuing of the SQL command FLASHBACK DATABASE statement. In RMAN, you can use this feature by issuing of the command FLASHBACK. If there is an event (human error) that insists the database to be flashed back to a point in time, you can do this in few steps: 1. Ensure that you are not dealing with some kind of media failure. The Flashback Database is useful only when your data is logically corrupted. 2. Find the desired point in time for the flashback operation. Usually it is the time just before the time when some human error caused a logical damage of the database data. You can calculate this as SCN or a Date (TIMESTAMP expression). Additionally, you can use a restore point or a time just before last RESETLOGS operation. A Log Sequence Number can be used in 10g R1 but it is not available as an option in 10g R2 (via SQL*Plus). It is still available as an option in RMAN. 3. Find the current oldest SCN and time to which the database can be backwarded:

SQL> SELECT oldest_flashback_scn,oldest_flashback_time FROM v$flashback_database_log;

If the desired time is after the oldest time currently recorded in the flashback log files then go to the next step 4. Ensure that there are not tablespaces with disabled flashback logging: SQL> SELECT NAME tbs_name, file_name db_file, flashback_on fb_logging, online_status status FROM v$tablespace,dba_data_files WHERE NAME=tablespace_name; If there are files with no important data that are excluded from flashback logging then you can follow Dealing with Excluded Tablespaces in case of Flashback Database Operations, which is not the scope of this document. Otherwise, go to the next step. 5. Ensure that all needed archived and redo logs (covering the whole time period between oldest_flashback_time column value and the time of failure or the restore point) are available: 5.1 Check the Guaranteed Restore point availability. SQL> col scn form 9999999999999999 SQL> SELECT NAME, SCN, TIME, DATABASE_INCARNATION#, GUARANTEE_FLASHBACK_DATABASE, STORAGE_SIZE FROM V$RESTORE_POINT WHERE GUARANTEE_FLASHBACK_DATABASE='YES' ; NAME SCN TIME DATABASE_INCAR# GUA STORAGE_SIZE -----------------------------------------------------------------------------------------------------TESTING1_2013_NOV_16_01_38 367953911831 16-NOV-13 01.37.47.000000000 AM 2 YES 9663676416 5.2 Find the current oldest SCN and time to which the database can be backwarded based on the available flashback logs. SQL> SELECT oldest_flashback_scn,to_char(oldest_flashback_time,'DD-MM-YYYY::HH24:MI:SS') FROM v$flashback_database_log; OLDEST_FLASHBACK_SCN TO_CHAR(OLDEST_FLASH --------------------------------------367953910842 16-11-2013::01:35:48

5.3 Check physical availability of archives using RMAN: RMAN> CROSSCHECK ARCHIVELOG FROM SCN oldest_flashback_scn;

Where oldest_flashback_scn is the value of the column oldest_flashback_scn in V$FLASHBACK_DATABASE_LOG. 5.3 Check logical availability of archives using RMAN: RMAN> REPORT UNRECOVERABLE; REPORT UNRECOVERABLE command reports all datafiles that cannot be recovered from existing backups because redo may be missing. You can check the logical availability of archived redo logs with the following SQL as well: SQL> SELECT * FROM v$archived_log WHERE first_change# > = oldest_flashback_scn AND status = 'A'; Where oldest_flashback_scn is the value of the column oldest_flashback_scn in V$FLASHBACK_DATABASE_LOG. 6. Find and write down the current SCN (or create a normal restore point if you are using 10g R2). Dont forget that the Flashback Database is a change on the database and it must be recorded if some failure occurs during this operation. SQL> SELECT current_scn FROM v$database; or SQL> CREATE RESTORE POINT before_flashback_operation; To map a time value and SCN, you can use the built-in SQL functions (available since 10g): SCN_TO_TIMESTAMP to find associated timestamp with this SCN TIMESTAMP_TO_SCN to find associated SCN with this timestamp SQL> SELECT current_scn, scn_to_timestamp(current_scn) FROM v$database; This timestamp mapping information is recorded in the SMON_SCN_TIME table. Oracle keeps the information in SMON_SCN_TIME table for a period of 5 days. 7. Restart the database in MOUNT stage 7.1 SQL> SHUTDOWN IMMEDIATE 7.2 SQL> STARTUP MOUNT For RAC environments, use: SQL> STARTUP MOUNT EXCLUSIVE If you want to be able to return the database to its state just as it was closed, you can create a restore point at this moment (restore points can be created even in MOUNT stage): SQL> CREATE RESTORE POINT just_after_shutdown; Or to find the last checkpointed SCN:

SQL> SELECT checkpoint_change# FROM v$database; In the next step, if you perform a few flashback operations and you need to return the database to its state just before to be closed, you will need the above SCN. 8. Flashes back the database to a point in time just as in the specified guaranteed restore point SQL> FLASHBACK DATABASE TO RESTORE POINT TESTING1_2013_NOV_16_01_38; 9. Open the Database with OPEN RESETLOGS clause: SQL> ALTER DATABASE OPEN RESETLOGS; 10. Creating Guaranteed restore point after completing flashback operation if required again. SQL> CREATE RESTORE POINT TESTING1_2013_DEC_05_01_38 GUARANTEE FLASHBACK DATABASE;

---------------------------------------------X------------------------------X------------------------------

11. Different types of Flashback the Database usage other than guaranteed RESTORE POINT.
For this example the point of time before the logical corruption is: As SCN: 4125962274 As Timestamp: 24.05.2006 15:10 In SQL it can be done by FLASHBACK DATABASE command. In RMAN it can be done by FLASHBACK command. 11.1. Flashes back the database to a point in time just as in the specified SCN: SQL> FLASHBACK DATABASE TO SCN 4125962274; /* returns database to its state as in the point in time marked with SCN 4125962274 */

11.2. Flashes back the database to a point in time just as in the specified TIMESTAMP (by using of custom TIMESTAMP value): SQL> FLASHBACK DATABASE TO TIMESTAMP to_timestamp('24.05.2006 15:10','dd.mm.yyyy hh24:mi'); /* returns database to its state as in the point in time 24.05.2006 15:10 */

11.3. Flashes back the database to a point in time just as in the specified TIMESTAMP (by using of SYSTIMESTAMP) SQL> FLASHBACK DATABASE TO TIMESTAMP (SYSTIMESTAMP -1/24); /* returns database to its state as in the point in time one hour ago */

11.4. Flashes back the database to a point in time just as in the specified TIMESTAMP (by using of SYSTIMESTAMP and INTERVAL):

SQL> FLASHBACK DATABASE TO TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' MINUTE); /* returns database to its state as in the point in time one minute ago */

11.5. Flashes back the database to a point in time just as in the specified restore point SQL> FLASHBACK DATABASE TO RESTORE POINT before_flashback_operation; /* returns database to its state as in the point in time marked with the restore point with name before_flashback_operation */

11.6. Flashbacks the database to the point in time just before the last RESETLOGS operation SQL> FLASHBACK DATABASE TO BEFORE RESETLOGS;

11.7. Flashes back the database to a SCN just before the specified SCN SQL> FLASHBACK DATABASE TO BEFORE SCN 4125962274;

11.8. Flashes back the database to a point in time one second before the specified TIMESTAMP SQL> FLASHBACK DATABASE TO BEFORE TIMESTAMP to_timestamp('24.05.2006 15:10','dd.mm.yyyy hh24:mi'); SQL> FLASHBACK DATABASE TO BEFORE TIMESTAMP (SYSDATE -1/24); SQL> FLASHBACK DATABASE TO BEFORE TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' MINUTE);

11.9. Flashes back the database to a point in time just before the specified restore point SQL> FLASHBACK DATABASE TO BEFORE RESTORE POINT before_flashback_operation;

11.10. Flashing back of the database via RMAN RMAN> FLASHBACK DATABASE TO SCN 4125962274; RMAN> FLASHBACK DATABASE TO TIMESTAMP (SYSDATE-1/24); RMAN> FLASHBACK DATABASE TO TIMESTAMP to_timestamp('24.05.2006 15:10','dd.mm.yyyy hh24:mi'); RMAN> FLASHBACK DATABASE TO RESTORE POINT before_flashback_operation; RMAN> FLASHBACK DATABASE TO BEFORE RESETLOGS;

III. RESTORE POINT Restore point can be normal restore point or Guaranteed Restore Points Normal restore point Creating a normal restore point assigns a restore point name to an SCN or specific point in time. If you use flashback features or point-in-time recovery, then you can use the name of the restore point instead of a time or SCN.

create a normal restore point SQL> CREATE RESTORE POINT before_flashback_operation; Flashes back the database to a point in time just as in the specified restore point SQL> FLASHBACK DATABASE TO RESTORE POINT before_flashback_operation; As the flashback retention target is not an absolute guarantee that flashback will be available. If space is needed for required files in the Flash Recovery Area, flashback logs may be deleted automatically. Normal restore points eventually age out of the control file if not manually deleted, so they require no ongoing maintenance. If the fast recovery area is full, then an archived redo log that is reclaimable according to the fast recovery area rules may be automatically deleted by the fast recovery area to make space for other files. In this case, any flashback logs that would require the use of that redo log file for the use of FLASHBACK DATABASE to normal restore point are also deleted. Guaranteed Restore Points Like a normal restore point, a guaranteed restore point serves as an alias for an SCN in recovery operations. A principal difference is that guaranteed restore points never age out of the control file and must be explicitly dropped. A guaranteed restore point enforces the retention of flashback logs required for Flashback Database to any SCN after the earliest guaranteed restore point. No file in the fast recovery area is eligible for deletion if it is required to satisfy a guaranteed restore point. Retention of flashback logs and other files required to satisfy the guaranteed restore point, in addition to files required to satisfy the backup retention policy, can cause the fast recovery area to fill completely. When you create a guaranteed restore point, with or without enabling full flashback database logging, you must monitor the space available in your fast recovery area. If no files are eligible for deletion from the fast recovery area because of the requirements imposed by your retention policy and the guaranteed restore point, then the database performs as if it has encountered a disk full condition. In many circumstances, this causes your database to halt. However, archived redo logs required to satisfy a guaranteed restore point may be deleted after they are backed up to disk or tape. When you use the RMAN FLASHBACK DATABASE command, if the archived redo logs required to satisfy a specified guaranteed restore point are not available in the fast recovery area, then they are restored from the backups. We are using guaranteed restore point in TESTING1 Server.

1. Creating Guaranteed restore point. CREATE RESTORE POINT TESTING1_2013_DEC_05_01_38 GUARANTEE FLASHBACK DATABASE; 2. Check the availability of guaranteed restore point:

SQL> col scn form 9999999999999999 SQL> SELECT NAME, SCN, TIME, DATABASE_INCARNATION#, GUARANTEE_FLASHBACK_DATABASE, STORAGE_SIZE FROM V$RESTORE_POINT WHERE GUARANTEE_FLASHBACK_DATABASE='YES' ; NAME SCN TIME DATABASE_INCAR# GUA STORAGE_SIZE -----------------------------------------------------------------------------------------------------TESTING1_2013_NOV_16_01_38 367953911831 16-NOV-13 01.37.47.000000000 AM 2 YES 9663676416

Das könnte Ihnen auch gefallen