RMAN Backup and Recovery Scenarios

Complete Closed Database Recovery. System tablespace is missing

If the system tablespace is missing or corrupted the database cannot be started up so a complete closed database recovery must be performed.

Pre requisites: A closed or open database backup and archived logs.

1. Use OS commands to restore the missing or corrupted system datafile to its original location, ie:

cp -p /user/backup/uman/system01.dbf /user/oradata/u01/dbtst/system01.dbf

2. startup mount;
3. recover datafile 1;
4. alter database open;

Complete Open Database Recovery. Non system tablespace is missing

If a non system tablespace is missing or corrupted while the database is open, recovery can be performed while the database remain open.

Pre requisites: A closed or open database backup and archived logs.

1. Use OS commands to restore the missing or corrupted datafile to its original location, ie:

cp -p /user/backup/uman/user01.dbf /user/oradata/u01/dbtst/user01.dbf

2. alter tablespace <tablespace_name> offline immediate;

3. recover tablespace <tablespace_name>;

4. alter tablespace <tablespace_name> online;

Complete Open Database Recovery (when the database is initially closed).Non system tablespace is missing

If a non system tablespace is missing or corrupted and the database crashed,recovery can be performed after the database is open.

Pre requisites: A closed or open database backup and archived logs.

1.AA startup; (you will get ora-1157 ora-1110 and the name of the missing datafile, the database will remain mounted)

2.AA Use OS commands to restore the missing or corrupted datafile to its original location, ie:

cp -p /user/backup/uman/user01.dbf /user/oradata/u01/dbtst/user01.dbf

3.AA alter database datafile3 offline; (tablespace cannot be used because the database is not open)

4.AA alter database open;

5.AA recover datafile 3;

6.AA alter tablespace <tablespace_name> online;

Recovery of a Missing Datafile that has no backups (database is open).

If a non system datafile that was not backed up since the last backup is missing,recovery can be performed if all archived logs since the creation of the missing datafile exist.
Pre requisites: All relevant archived logs.

1.AA alter tablespace <tablespace_name> offline immediate;

2.AA alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf';

3.AA recover tablespace <tablespace_name>;

4.AA alter tablespace <tablespace_name> online;

If the create datafile command needs to be executed to place the datafile on a location different than the original use:

alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf' as '/user/oradata/u02/dbtst/newdata01.dbf'

Restore and Recovery of a Datafile to a different location.

If a non system datafile is missing and its original location not available, restore can be made to a different location and recovery performed.
Pre requisites: All relevant archived logs.

1.AAA Use OS commands to restore the missing or corrupted datafile to the new location, ie:

cp -p /user/backup/uman/user01.dbf /user/oradata/u02/dbtst/user01.dbf

2.AAA alter tablespace <tablespace_name> offline immediate;

3.AAA alter tablespace <tablespace_name> rename datafile '/user/oradata/u01/dbtst/user01.dbf' to '/user/oradata/u02/dbtst/user01.dbf';

4.AAA recover tablespace <tablespace_name>;

5.AAA alter tablespace <tablespace_name> online;

Control File Recovery

Always multiplex your controlfiles. Controlfiles are missing, database crash.
Pre requisites: A backup of your controlfile and all relevant archived logs.

1.AAA startup; (you get ora-205, missing controlfile, instance start but database is not mounted)

2.AAA Use OS commands to restore the missing controlfile to its original location:

cp -p /user/backup/uman/control01.dbf /user/oradata/u01/dbtst/control01.dbf
cp -p /user/backup/uman/control02.dbf /user/oradata/u01/dbtst/control02.dbf

3.AAA alter database mount;

4.AAA recover automatic database using backup controlfile;

5.AAA alter database open resetlogs;

6.AAA make a new complete backup, as the database is open in a new incarnation and previous archived log are not relevant.

Incomplete Recovery, Until Time/Sequence/Cancel

Incomplete recovery may be necessaire when an archived log is missing, so recovery can only be made until the previous sequence, or when an important object was dropped, and recovery needs to be made until before the object was dropped.

Pre requisites: A closed or open database backup and archived logs, the time or sequence that the 'until' recovery needs to be performed.

1.A If the database is open, shutdown abort

2.A Use OS commands to restore all datafiles to its original locations:

cp -p /user/backup/uman/u01/*.dbf /user/oradata/u01/dbtst/

cp -p /user/backup/uman/u02/*.dbf /user/oradata/u01/dbtst/

cp -p /user/backup/uman/u03/*.dbf /user/oradata/u01/dbtst/

cp -p /user/backup/uman/u04/*.dbf /user/oradata/u01/dbtst/

etc...

3.A startup mount;

4.A recover automatic database until time '2004-03-31:14:40:45';

5.A alter database open resetlogs;

6.A make a new complete backup, as the database is open in a new incarnation and previous archived log are not relevant.Alternatively youAA may use instead of until time, until sequence or until cancel:
recover automatic database until sequence 120 thread 1; OR
recover database until cancel;

Rman Recovery Scenarios

Rman recovery scenarios require that the database is in archive log mode, and that backups of datafiles, control files and archived redolog files are made using Rman. Incremental Rman backups may be used also.

Rman can be used with the repository installed on the archivelog, or with a recovery catalog that may be installed in the same or other database.

Configuration and operation recommendations:

Set the parameter controlfile autobackup to ON to have with each backup a
controlfile backup also:

configure controlfile autobackup on;

set the parameter retention policy to the recovery window you want to have,

ie redundancy 2 will keep the last two backups available, after executing delete obsolete commands:

configure retention policy to redundancy 2;

Execute your full backups with the option 'plus archivelogs' to include your archivelogs with every backup:

backup database plus archivelog;

Perform daily maintenance routines to maintain on your backup directory the number of backups you need only:

crosscheck backup;

crosscheck archivelog all;

delete noprompt obsolete backup;

To work with Rman and a database based catalog follow these steps:

1. sqlplus /

2. create tablespace repcat;

3. create user rcuser identified by rcuser default tablespace repcat temporary tablespace temp;

4. grant connect, resource, recovery_catalog_owner to rcuser

5. exit

6. rman catalog rcuser/rcuserAAAAAAAAA # connect to rman catalog as the rcuser

7. create catalogAAAAAAAAAAAAAAAAAAAA # create the catalog

8. connect target /AAAAAAAAAAAAAAAAAA #

Complete Closed Database Recovery. System tablespace is missing

In this case complete recovery is performed, only the system tablespace is missing,so the database can be opened without reseting the redologs.

1.A rman target /

2.A startup mount;

3.A restore database;

4.A recover database;

5.A alter database open;

Complete Open Database Recovery. Non system tablespace is missing,database is up

1.AA rman target /

2.AA sql 'alter tablespace <tablespace_name> offline immediate';

3.AA restore datafile 3;

4.AA recover datafile 3;

5.AA sql 'alter tablespace <tablespace_name> online';

Complete Open Database Recovery (when the database is initially closed).Non system tablespace is missing

A user datafile is reported missing when tryin to startup the database. The datafile can be turned offline and the database started up. Restore and recovery are performed using Rman. After recovery is performed the datafile can be turned online again.

1.AAA sqlplus /nolog

2.AAA connect / as sysdba

3.AAA startup mount

4.AAA alter database datafile '<datafile_name>' offline;

5.AAA alter database open;

6.AAA exit;

7.AAA rman target /

8.AAA restore datafile '<datafile_name>';

9.AAA recover datafile '<datafile_name>';

10.AA sql 'alter tablespace <tablespace_name> online';

Recovery of a Datafile that has no backups (database is up).

If a non system datafile that was not backed up since the last backup is missing,recovery can be performed if all archived logs since the creation of the missing datafile exist. Since the database is up you can check the tablespace name and put it offline. The option offline immediate is used to avoid that the update of the datafile header.

Pre requisites: All relevant archived logs.

1.AAA sqlplus '/ as sysdba'

2.AAA alter tablespace <tablespace_name> offline immediate;

3.AAA alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf;

4.AAA exit

5.AAA rman target /

6.AAA recover tablespace <tablespace_name>;

7.AAA sql 'alter tablespace <tablespace_name> online';

If the create datafile command needs to be executed to place the datafile on a location different than the original use:

alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf' as '/user/oradata/u02/dbtst/newdata01.dbf'

Restore and Recovery of a Datafile to a different location. Database is up.

If a non system datafile is missing and its original location not available, restore can be made to a different location and recovery performed.

Pre requisites: All relevant archived logs, complete cold or hot backup.

1.AAA Use OS commands to restore the missing or corrupted datafile to the new location, ie:

cp -p /user/backup/uman/user01.dbf /user/oradata/u02/dbtst/user01.dbf

2.AAA alter tablespace <tablespace_name> offline immediate;

3.AAA alter tablespace <tablespace_name> rename datafile '/user/oradata/u01/dbtst/user01.dbf' to '/user/oradata/u02/dbtst/user01.dbf';

4.AAA rman target /

5.AAA recover tablespace <tablespace_name>;

6.AAA sql 'alter tablespace <tablespace_name> online';

Control File Recovery

Always multiplex your controlfiles. If you loose only one controlfile you can replace it with the one you have in place, and startup the Database. If both controlfiles are missing, the database will crash.

Pre requisites: A backup of your controlfile and all relevant archived logs. When using Rman alway set configuration parameter autobackup of controlfile to ON. You will need the dbid to restore the controlfile, get it from the name of the backed up controlfile.It is the number following the 'c-' at the start of the name.

1.AA rman target /

2.AA set dbid <dbid#>

3.AA startup nomount;

4.AA restore controlfile from autobackup;

5.AA alter database mount;

6.AA recover database;

7.AA alter database open resetlogs;

8.AA make a new complete backup, as the database is open in a new incarnation and previous archived log are not relevant.

Incomplete Recovery, Until Time/Sequence/Cancel

Incomplete recovery may be necessaire when the database crash and needs to be recovered, and in the recovery process you find that an archived log is missing. In this case recovery can only be made until the sequence before the one that is missing.

Another scenario for incomplete recovery occurs when an important object was dropped or incorrect data was committed on it.

In this case recovery needs to be performed until before the object was dropped.

Pre requisites: A full closed or open database backup and archived logs, the time or sequence that the 'until' recovery needs to be performed.

1.AA If the database is open, shutdown it to perform full restore.

2.AA rman target /

3.AA startup mount;

4.AA restore database;

5.AA recover database until sequence 8 thread 1; # you must pass the thread, if a single instance will always be 1.

6.A alter database open resetlogs;

7.A make a new complete backup, as the database is open in a new incarnation and previous archived log are not relevant.Alternatively you may use instead of until sequence, until time, ie: '2004-12-28:01:01:10'.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
备份恢复难得的经典力作 Getting Started with RMAN in Oracle Database 11g 1 Oracle Database 11g Backup and Recovery Architecture Tour . . . . . . . . . . . . . . 3 2 Introduction to the RMAN Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 PART II Setup Principles and Practices 3 RMAN Setup and Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 4 Media Management Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 5 Oracle Secure Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 6 Backing Up to Amazon Web Services Using the Oracle Secure Backup Cloud Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 7 Enhancing RMAN with VERITAS NetBackupTM for Oracle . . . . . . . . . . . . . . . . . . 153 8 Configuring HP Data Protector for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 9 RMAN and Tivoli Storage Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 10 Using the Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 11 RMAN Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 12 RMAN Restore and Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 PART III Using RMAN Effectively 13 Using Oracle Enterprise Manager for Backup and Recovery . . . . . . . . . . . . . . . . 307 14 RMAN Advanced Recovery Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 15 Surviving User Errors: Flashback Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 16 Maintaining RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 17 Monitoring and Reporting on RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 18 Performance Tuning RMAN Backup and Recovery Operations . . . . . . . . . . . . . . 445 PART IV RMAN in the Oracle Ecosystem 19 Duplication: Cloning the Target Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 20 RMAN and Data Guard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 21 RMAN and Real Application Clusters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501 22 RMAN in Sync and Split Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517 23 RMAN in the Workplace: Case Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531 PART V Appendixes A RMAN Syntax Reference Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559 B RMAN Scripting Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621 C Setting Up an RMAN Test Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值