Rman recovery Scheme and Oracle heterogeneous recovery _oracle

Source: Internet
Author: User
Tags oracle database

Note:
The prerequisite for ① recovery is that the backup is done
② Full Recovery database is the database encountered a failure, at the time of recovery did not lose any of the submitted things data recovery
Incomplete recovery database is a database failure, the recovery of the loss of some data recovery
③ needs to set environment variables under Linux, that is, the instance name of the ORACLE database that needs to be restored: Export ORACLE_SID=ORCL
④ When you start a database with resetlogs, you should make a full backup of the database

I. Recovery programme
1, the loss of data files, to complete recovery

Copy Code code as follows:

Rman>startup Mount;
Rman>restore database;
Rman>recover database;
Rman>sql ' ALTER DATABASE open ';

2, the loss of redo log files, do not complete recovery
Copy Code code as follows:

Sql>startup Mount;
Sql>recover database until cancel;
Sql>alter database open resetlogs;

3, the loss of data files, control files and redo log files, incomplete recovery
Copy Code code as follows:

Rman>startup Nomount;
Rman>restore controfile from Autobackup;
Rman>alter database Mount;
Rman>restore database;
Sql>recover database using Backup controlfile until cancel;
Sql>alter database open resetlogs;

4, the loss of initialization files, control file data files and redo log files, incomplete recovery
Copy Code code as follows:

Sql>startup nomount pfile= ' D:\oracle\product\10.2.0\db_1\admin\orcl\pfile\init.ora.27201414210 '; #pfile的路径
Rman>restore SPFile from Autobackup;
Sql>shutdown immediate;
Sql>startup Nomount;
Rman>restore controlfile from Autobackup;
Rman>alter database Mount;
Rman>restore database;
Sql>recover database using Backup controlfile until cancel;
Sql>alter database open resetlogs;

5, based on point-in-time recovery (commonly used)
Copy Code code as follows:

Rman>startup Mount;
Rman>restore database;
Rman>sql ' alter session set nls_date_format= "YYYYMMDD hh24:mi:ss"; #设置显示时间格式
Rman>recover database until time ' 20140312 17:07:00 '; #把数据库恢复到2014-03-12 17:07:00 at this point in time
Rman>sql ' ALTER DATABASE open resetlogs ';

6, based on the SCN recovery
Copy Code code as follows:

Rman>startup Mount;
Rman>restore database;
Rman>recover database until SCN 963915;
Rman>sql ' ALTER DATABASE open resetlogs ';

① Query current SCN number:
Copy Code code as follows:

Sql>select Dbms_flashback.get_system_change_number from dual;

② according to the SCN number query time:
Copy Code code as follows:

Sql>select To_char (Scn_to_timestamp (963959), ' Yyyymmdd Hh24:mi:si ') from dual;

③ Query the SCN number according to time:
Copy Code code as follows:

Sql>select TIMESTAMP_TO_SCN (to_date (' 20140309 17:55:10 ', ' yyyymmdd hh24:mi:ss ')) from dual;

④ query for a period of time the SCN number:
Copy Code code as follows:

Sql>select * FROM (select TIME_DP,SCN to Smon_scn_time ORDER by time_dp Desc) where rownum<20;

7, in-depth understanding of incarnation: is to be able to cross resetlogs data recovery
① every time resetlogs will make incarnation + 1, if you want to restore to the previous incarnation SCN, you need to first restore to the previous incarnation;

②incarnation 12 includes the SCN 900000 spot, so when incarnation 12 does the until SCN, it restores to the current incarcation SCN; But according to our needs, we need incarn. ation 11 's SCN 900000, so you need to switch incarnation to incarnation 11 to retrieve the data we need.
Rman>reset database to incarnation 11;

8, recover database Four statement difference
①sql>recover database using Backup Controlfile
If the current control file is lost, when the control file is restored with a cold backup, Used to tell Oracle not to use the SCN in Controlfile as the end point for recovery.
②sql>recover database until cancel
Specifies the endpoint manually if the current/active redo is lost.
③sql>recover database using Backup controlfile until cancel;
If the current controlfile is lost and current/active redo is lost, the archive log will be automatically applied to maximize recovery;
④sql>recover database until cancel using Backup controlfile;
If the current controlfile is lost and current/active redo is lost, the SCN in the old redo is the end of the recovery because no archived logs are applied and all data is lost.

To understand the recover database using Backup Controlfile, first understand the recover database; in the normal recover database or recover tablespace, recover data At file, Oracle uses the redo entry of the archive log and redo log to restore the associated datafile block to the "SCN as recorded in the current Controlfile", whichever is the current controlfile record of the SCN. "And in some cases Oracle needs to restore the data to the point where the SCN is more than the current Controlfile record (for example, control file is backup Controlfile, or Controlfile is based on trace The Create.   , you need to use the using Backup Controlfile. Recovery is not limited by the "SCN recorded by current Controlfile". The limitation at this time comes from your statement (until time, until SCN), or the available archive log (until cancel). If the control files are lost and restore is backed up by the control files, you must use the Using Backup Controlfile option. Until cancel is an incomplete recovery, that is, current/active redo is missing, or an archive file is missing from the restore database.
Conclusion:
If you have an old database backup that uses the recover database or recover database using Backup controlfile, you do not lose data if the archive log and the online log are all intact.
If the archive log or online log (active, current) loss occurs after the backup data file restore, use the Recover database using Backup Controlfile until cancel, You can achieve maximum recovery.

Second, Rman heterogeneous recovery (the source and target database instance name to be consistent)

1, the source database for backup

Copy Code code as follows:

Rman>backup database plus archivelog;
Rman>backup current Controlfile;

2, the source database to generate the parameters of the file, modified to pass to the target database
3, under the Windows platform for recovery
Copy Code code as follows:

C:\>oradim-new-sid ORCL #创建一个orcl服务
C:\>set ORACLE_SID=ORCL
C:\>sqlplus "/as sysdba";
Sql>startup nomount pfile= ' C:\INITorcl.ORA ';
Sql> create SPFile from pfile= ' C:\INITorcl.ORA ';
sql> shutdown immediate;
sql>exit;
C:\>set ORACLE_SID=ORCL
C:\>rman target/
Rman>startup Nomount;
Rman>restore controlfile to ' target database controls location of file placement and name ' from ' Backup control file placement ';
Rman>alter database Mount;
Rman>catalog start with ' Place of backup set '; #向控制文件中添加备份集
Rman>crosscheck backup;
Rman>report schema;

Write the bottom script and run
Copy Code code as follows:

Run
{
Set newname for DataFile 1
To ' C:\oracle\product\10.2.0\oradata\orcl\SYSTEM.  DBF '; Position of #实例中SYSTEM. DBF Placement
Set newname for DataFile 2
To ' C:\oracle\product\10.2.0\oradata\orcl\UNDOTBS1. DBF ';
Set NewName for DataFile 3
To ' C:\oracle\product\10.2.0\oradata\orcl\SYSAUX. DBF ';
Set newname for DataFile 4
To ' C:\oracle\product\10.2.0\oradata\orcl\USERS. DBF ';
Set NewName for DataFile 5
To ' C:\oracle\product\10.2.0\oradata\orcl\BANK_DATA02. DBF ';
Restore database;
Switch datafile all;
}
Rman>recover database;
Rman>sql ' ALTER DATABASE open resetlogs ';

Restore success

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.