Tuesday, August 25, 2009

How to change Flash Recovery Area to a new location.

How to change Flash Recovery Area to a new location ?
-----------------------------------------------------

If you need to move the Flash Recovery Area of your database to a new location,
invoke SQL*Plus to change the DB_RECOVERY_FILE_DEST initialization parameter.
For example:

ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='+disk1' SCOPE=BOTH SID='*';

After you change this parameter, all new Flash Recovery Area files will be
created in the new location.

The permanent files (control files and online redolog files), flashback logs
and transient files can be left in the old Flash Recovery Area location. The
database will delete the transient files from the old Flash Recovery Area
location as they become eligible for deletion.

For the FLASHBACK logfiles to be able to to pick up the new 'db_recovery_file_dest' location,
the flashback option needs to be toggled off and on.

This can be done like this:
- Shutdown the Database
- Startup mount the Database:
SQL> startup mount;
- Toggle the Flashback off:
SQL> alter database flashback off;
- Toggle the Flashback on:
SQL> alter database flashback on;
- Open the Database:
SQL> alter database open;

If you need to actually move your current permanent files, transient files, to the new Flash Recovery Area, then follow the following steps:

1) To move the existing backupsets and archived redo log files,use the following
command:

RMAN> BACKUP AS COPY ARCHIVELOG ALL DELETE INPUT;
RMAN> BACKUP DEVICE TYPE DISK BACKUPSET ALL DELETE INPUT;

2) To move the datafile copies. Run the below command for each datafile copy:

RMAN> BACKUP AS COPY DATAFILECOPY DELETE INPUT;

where the is the datafilecopy name in the old recovery area.

3) To move the controlfile from the old Flash Recovery Area to new one.
Change the location in the parameter CONTROL_FILES to the new location
and restart the instance in NOMOUNT.

RMAN> RESTORE CONTROLFILE FROM 'filename_of_old_control_file';

4) To move the online redo logs. Use the commands to add a a log file stored in
the new Flash Recovery Area and drop the logfile in the old Flash Recovery Area
for each redo log group.

SQL> alter database add logfile size 100M;
SQL> alter database drop logfile 'name of the old redo log';

Oracle will clean up transient files remaining in the old Flash Recovery Area
location as they become eligible for deletion.

Enable flash recovery area .

1.First set up the database in archive log mode.
2.Next set up the flash back
SQL> show parameter recovery

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string G:\oracle\product\10.2.0/flash
_recovery_area
db_recovery_file_dest_size big integer 2G
recovery_parallelism integer 0
SQL> select FLASHBACK_ON from v$database;

FLASHBACK_ON
------------------
NO

3.Shutdown the database and mount the database ,And enable flash back on database.
===================================================================================
SQL> startup mount;
ORACLE instance started.

Total System Global Area 574619648 bytes
Fixed Size 1250212 bytes
Variable Size 171969628 bytes
Database Buffers 394264576 bytes
Redo Buffers 7135232 bytes
Database mounted.
SQL> alter database flashback on;

Database altered.

SQL> alter database open;

Database altered.

SQL> select FLASHBACK_ON from v$database;

FLASHBACK_ON
------------------
YES

Followers