RMAN @ its best ( Switch Database )

Reading time: 2 - 4 minutes

You can minimize the downtime to great extent with RMAN while recovering the tera byte database.

The main problem of Tera byte Database would be restore and recovery time.

Its takes hell lot of time while restoring all the datafile to its location before you can perform recovery.

I have one 2 TB database and it take 48 hours to restore and then recovery......

I came across RMAN's great feature which has helped a lot me in solving my issue.

With RMAN you can create copy of live Database and perform the switch to copy when main database is not available due to any problem.

First of all make the proper configuration with RMAN and then proceed,

RMAN>CONFIGURE BACKUP OPTIMIZATION ON;

A

RMAN >CONFIGURE CONTROLFILE AUTOBACKUP ON;

First create full copy of running database using following command.

RMAN>run {
RMAN>BACKUP AS COPY DATABASE TAG 'DB_COPY';
RMAN>}

Once you have full copy of Adatabase then you can schedule cron job to take incremental copy of database.

RMAN>run {
RMAN>BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'DB_COPY' DATABASE PLUS ARCHIVELOG DELETE INPUT;
RMAN>copy current controlfile to '<Location Where you want to copy>';
RMAN>}

Once you need to restore the DB then you can simplly perform switch to copy of the database using following command.

RMAN>switch database to copy;

Please note that Copy of database would be created in FRA and hence after performing the switch you need to change the db_recovery_dest parameter and then you can again create the full copy of the databnase.

If you dont change db_recovery_area and try to create copy once again then it will overwrite the running database.

You can also define the retention policy for copies of database with following commands.

RMAN>CONFIGURE RETENTION POLICY TO REDUNDANCY 1;

or

RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS;

You can relocate your datafiles according to your needs using RMAN.

RMAN> backup as copy datafile <datafile name | datafile number> format '<new location>';
RMAN> switch datafile <datafile name | datafile number> to copy;

Please use following command to see all available copies.

RMAN>list copy of database;

or

RMAN>list copy of datafile <File # or File name>

You can delete the copy of database with following command.

RMAN>delete copy of database;

  • Share/Bookmark

3 Responses to “RMAN @ its best ( Switch Database )”

  • Hi Dev – when you switch the database to copy, the original datafile names are changed. How do you rename the datafiles back to their original names?

  • admin:

    Hi Gavin,

    You are right switch database command will rename the datafile and it will update controlfile with new name.

    Later on if you want to change the name of datafile than you need to take tablespace offline using following steps.

    SQL>ALTER TABLESPACE cust_ts OFFLINE;

    linux> mv ‘OLDFILE.DBF ‘ ‘NEWFILE.DBF’

    SQL>ALTER TABLESPACE cust_ts RENAME datafile
    ‘/u01/app/oracle/mysid/oldname.dbf’
    TO
    ‘/u01/app/oracle/mysid/newname.dbf’ ;

    Regards,
    Dev

  • Magda:

    Hi Dev,

    Could you please clarify these 2 aspects for me?
    1. What is the reason of backup database “PLUS ARCHIVELOG” for the image copy incremental level 1? Is it not enough to backup just the database?…
    2. What is your opinion about backup on ASM in 11.2?
    Meaning: would you consider a good idea to have both the original database and the image copy on the same disk group?
    How can one rename the datafiles after database switch on ASM?

    Thank you for your time,

    Magda

Leave a Reply