Rman switch to copy

来源:互联网 发布:李卫当官 知乎 编辑:程序博客网 时间:2024/06/06 16:40

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;